I have a partial that has the following code: <% if product.prd_big_image.nil? %> <img alt="Image" src="/images/empty.jpg"> <% else %> <%= image_tag url_for_file_column(:product, :prd_big_image, "normal") %> <% end %> and get the following error You have a nil object when you didn''t expect it! The error occurred while evaluating nil.prd_big_image_relative_path If I run the code in a normal html.erb (not a partial) it works fine, just has issues within the partial any ideas? -- 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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Sep-16 03:27 UTC
Re: url_for_file_column within if within a partial
Michael Moulsdale wrote:> I have a partial that has the following code: > > <% if product.prd_big_image.nil? %> > <img alt="Image" src="/images/empty.jpg"> > <% else %> > <%= image_tag url_for_file_column(:product, :prd_big_image, > "normal") %> > <% end %> > > and get the following error > > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.prd_big_image_relative_path > > If I run the code in a normal html.erb (not a partial) it works fine, > just has issues within the partial > > any ideas?You need to assign @product = product somewhere in the partial. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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 -~----------~----~----~----~------~----~------~--~---