Reputation: 17
In my controller I have:
- @items.each do |item|
= render :partial => 'item', :locals => { :item => item, :draggable => true }
And in the item
partial I have:
%span{:id => "item_#{item.id}", :class => 'item'}
= item.name
- if defined?(draggable)
= draggable_element "item_#{item.id}", :revert => true
This is not working, however, because defined?(draggable)
returns false
. The draggable_element
is never rendered.
I know that item
is passed through :locals
because the rest of the partial renders. If I change the partial to read:
- if defined?(item)
= draggable_element "item_#{item.id}", :revert => true
Then the draggable_element
is rendered.
Any idea why :draggable
is not getting passed to the partial?
Upvotes: 0
Views: 413
Reputation: 23450
I've solved this problem in the past by throwing this into the top of the partial.
<% draggable ||= nil %>
That allows me to do
<% if draggable %>
So long as I don't try to make the distinction between draggable being nil and never being passed.
Upvotes: 0