Ask A Question


You’re not receiving notifications from this thread.

Restricting Javascript Widgets to Registered Sites Discussion

In this example you first render the javascript and make another call to API via fetch and check the domain in API controller. Is there a specific reason for that?

Isn't it better to check the domain at embeds-controller and if domain is not registered, we will not have to render any javascript on client side.

We can get the domain by checking headers with something like URI.parse( request.env["HTTP_REFERER"])


I'm getting a NoMethodError (undefined method `sites' for nil:NilClass) error from the part at 18:37, any suggestions?


Sites is scoped to current_user, so you need to log in first.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 76,990+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.