Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails UJS tries to execute response as JavaScript, gets blocked by CSP #29

Open
vitobotta opened this issue Apr 22, 2020 · 0 comments
Open

Comments

@vitobotta
Copy link

Hi! I am trying to use this gem but can't get it to work. I'm on Rails 6, and it seems that something in Rails UJS interferes because the content type is text/javascript and therefore it tries to add a script tag to the page:

document.head.appendChild(script).parentNode.removeChild(script);

I have simply added the gem, and the create action is like this:

  def create
    @blog = current_user.blogs.new(create_blog_params)
    authorize @blog

    respond_to do |format|
      if @blog.save
        format.html { redirect_to @blog }
      else
        format.html { render :new }
      end
    end
  end

The form is like this:

<%= form_with model: @blog, html: { novalidate: "novalidate" }, class: "form max-w-2xl p-8" do |f

What am I missing?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant