Lee.Longmore-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-May-16 06:26 UTC
Passing hashes in a :collection
I am trying to pass an array of hashes to a partial via a :collection. render :partial => ''property'', :collection => @enriched_properties where @enriched_properties is an array of hashes: :property => property # a property object :is_visible => property.visible?(member) and so on... In my partial, the local variable "property" is only showing the contents of the property object. I am not able, for example, to say <%= h property[:is_visible].inspect %> Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 16, 2007, at 8:26 AM, Lee.Longmore-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org wrote:> > I am trying to pass an array of hashes to a partial via a :collection. > > render :partial => ''property'', :collection => @enriched_properties > > where @enriched_properties is an array of hashes: > > :property => property # a property object > :is_visible => property.visible?(member) > > and so on... > > In my partial, the local variable "property" is only showing the > contents of the property object. > > I am not able, for example, to say <%= h property[:is_visible].inspect > %>Yeah, hashes do not work because the code behind render collection handles them as a special case. Replace the call with an explicit loop. -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---