dev85
dev85

Reputation: 637

render partial with local variable in js.erb file - unexpected =>, expecting ')'

I have following file. Displaying error:

SyntaxError (/home/ubuntu/workspace/app/views/responses/destroy.js.erb:1: syntax error, unexpected =>, expecting ')'
....append=( j render (:partial => "projects/new_response", :lo...

I cant found, what wrong with code?

destroy.js.erb

$('.responses').replaceWith('<%= j render (:partial => "projects/new_response", :locals => { project: @project } )%> ');

How write correct?

Upvotes: 1

Views: 268

Answers (1)

Uzbekjon
Uzbekjon

Reputation: 11813

Remove the space here:

#     |-  HERE
render(:partial => 

Or, surround your j method call params. Basically, Ruby can't figure out which is whose params when you have hash in your arguments list:

j(render (:partial =>  ...) )

Upvotes: 1

Related Questions