0

I have a rails app that I need to use Ajax to post on my model.

I have only this line in my filename.js.erb

$('#new-band a').html('<%= j render 'form'%>')

Here is my error:

Showing /<snip>/ajax/app/views/layouts/application.html.erb where line #8 raised:

undefined method `render' for #<#<Class:0x00007fad63eb3b98>:0x00007fad5e2c13f8>
2
  • 1
    I don't think this is the answer but try adding parens: j(render('form')) to be sure it is being parsed as intended by Ruby. Commented Oct 3, 2018 at 12:29
  • Where is filename.js.erb being called? can you add the controller ? Commented Oct 3, 2018 at 16:54

2 Answers 2

1

Try changing your single quote to double quotes around the form. For example:

$('#new-band a').html('<%= j render 'form'%>')

Changes to:

$('#new-band a').html('<%= j render "form" %>')
Sign up to request clarification or add additional context in comments.

Comments

0

You can try this:

$('#new-band a').html("<%= j render(:partial => 'form') %>");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.