0

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

terrorista
  • 227
  • 1
  • 14
  • 1
    Possible duplicate of [Rails 3, passing local variable to partial](http://stackoverflow.com/questions/6279651/rails-3-passing-local-variable-to-partial) –  Mar 31 '16 at 02:16

3 Answers3

3

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

Community
  • 1
  • 1
1

you can pass a variable like this

<%= render partial: 'partial_name', locals: {id: '1'} %>
Narasimha Reddy - Geeker
  • 3,074
  • 2
  • 15
  • 21
0

Try this syntax out:

<%= render @performance_indicator.improvement_actions, locals: { local_variable: 1 %>
# then <%= local_variable %>
Ho Man
  • 2,208
  • 10
  • 16