willcodejavaforfood
willcodejavaforfood

Reputation: 44103

How to pass a variable to render?

This is the line in my new.js.erb that calls the render function

$('.node_container').append("<%= escape_javascript(render(@care_point, :locals => {:care_map => @care_map}))%>");

Gives error message:

ActionView::Template::Error (undefined local variable or method `care_map'

for my partial _care_point.html.erb:

<%= link_to 'Delete', [care_map, care_point], :confirm => "Are you sure?", :method => :delete, :remote => true, :class => 'delete' %>

Upvotes: 1

Views: 353

Answers (1)

apneadiving
apneadiving

Reputation: 115541

To pass locals variables, you must use

render :partial => partial_name, :locals => { # all your vars here }

and not the mere:

render @var

See doc here, para 3.4.4.

Upvotes: 1

Related Questions