Reputation: 227
How can I pass a variable to a partial using this code? :
<%= render @performance_indicator.improvement_actions.order("created_at DESC") %>
I want to pass "id=1" and then in _improvement_action, use that variable like:
<%= id %>
EDIT:
This is my improvement_action partial:
https://gist.github.com/luisamaro0/6597084f2de1dc33cde7c014ea9f23a5
Upvotes: 0
Views: 212
Reputation: 2345
Try this syntax out:
<%= render @performance_indicator.improvement_actions, locals: { local_variable: 1 %>
# then <%= local_variable %>
Upvotes: 0
Reputation: 3860
you can pass a variable like this
<%= render partial: 'partial_name', locals: {id: '1'} %>
Upvotes: 1
Reputation:
You can pass a local variable like so:
render "a_partial", :a_local_variable => whatever, :another_variable => another
See this question for more details: Rails 3, passing local variable to partial
Upvotes: 3