Jebus
1
Why am I getting undefined local variable ‘contact’ in my partial.
This is code I used to render the partial, works in lots of other places
<%= render (:partial => ‘list’, :collection => @contacts) %>
in my parital I have
<%= contact.first_name %>
if I write this way it works fine
<% for contact in @contacts %>
<%= render (:partial => ‘list’, :locals => {:contact => contact } ) %>
<% end %>
@contacts is being loaded with a paginate in my controller. any ideas ?
joe
Jebus
2
For your render method use
:partial => ‘contact’
Kent.
Jebus
3
Hi Jebus ~
The local variable will have the same name as the partial. So in this
case, your local variable is named list. So list.first_name will
work.
If you want to use contact, rename your partial to _contact.rhtml.
~ Ben
On 2/7/06, Jebus [email protected] wrote:
<%= render (:partial => ‘list’, :locals => {:contact => contact } ) %>
<% end %>
@contacts is being loaded with a paginate in my controller. any ideas ?
joe
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Ben R.
http://www.benr75.com