I am really confused with how rendered paginated objects work. Take this for example:
When I run
<%= render :partial => 'feeds/share_item', collection: @share_items %>
<%= will_paginate @share_items %>
I can go to _share_item.html.erb and inside of it I can do this…
<%= link_to "Delete", share_item, method: :delete,
data: { confirm: "Are you sure you want to delete this?" },
class: "btn-link", title: share_item.content %>
…and it will have the Delete link and all goes well.
But, while still in _share_item.html.erb, if I replace that with…
<%= render :partial => 'shared/delete' %>
…I get this:
undefined local variable or method 'share_item' for #<#<Class:0xaf0b888>:0xb15cb3c>
Why?
I have been trying to resolve this issue for quite some time, because I have a lot of forms and links cluttered in my partial. I want to be able to render said forms and links via another partial.
Thanks for your help.
Right now, the variable share_item is empty, as it has not been supplied to the partial.
You would need to do something like this:
Or, the slightly more terse
Or, even better:
You can find more info here.