I would like to generate a select list from multiple associations. Do
not know what the problem is. Hope anyone can
help.
the code below gives me a: "You have a nil object when you
didn''t
expect it!
The error occurred while evaluating nil.filename"
----------in the controller----------
@skinType = Furni.find(:all, :include =>[:imageasset => {:skin =>
[:skintype, :skinstyle]}]).map {|st| [st.imageasset. filename, st.id] }
------ in the view ------
<% form_tag( ''list'') do %>
<%= select_tag :skin, options_for_select(["View-All"]+@skinType,
@skintype_id.to_i), :onChange =>
"location.href=''http://www.furnii.com/skins/list?skintype_id=''+options[selectedIndex].value"
%>
<% end %>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Oct-02 08:29 UTC
Re: multiple associations in select list not working
On Oct 2, 4:10 am, Sam Ginko <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I would like to generate a select list from multiple associations. Do > not know what the problem is. Hope anyone can > help. > > the code below gives me a: "You have a nil object when you didn''t > expect it! > The error occurred while evaluating nil.filename" > > ----------in the controller---------- > @skinType = Furni.find(:all, :include =>[:imageasset => {:skin => > [:skintype, :skinstyle]}]).map {|st| [st.imageasset. filename, st.id] }It''s telling you that there is a Furni whose imageasset is nil. Fred> > ------ in the view ------ > > <% form_tag( ''list'') do %> > <%= select_tag :skin, options_for_select(["View-All"]+@skinType, > @skintype_id.to_i), :onChange => > "location.href=''http://www.furnii.com/skins/list?skintype_id=''+options[selectedIndex].value" > %> > <% end %> > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---