ruby on rails - Passing parameters to partial view -
ruby on rails - Passing parameters to partial view -
i have view displays multiple images , images' associated tags. decided utilize partial view each image , tags, having problem passing in image object partial view. here main view's relevant code:
<table> <% @images.each |i| %> <tr> <%= render :partial => :image_tag, :image => %> </tr> <% end %> </table> here partial view's relevant code (partial view named _image_tag.html.erb):
<table> <%= image.id %> <%= image_tag image.src %> </table> i read in this thread can pass in image object way doing it. tried passing in id through options hash on render method, , didn't work. error getting is:
undefined method `model_name' symbol:class centered around line calling render :partial in main view.
<%= render :partial => "image_tag", :locals => {:image => i} %>
is how pass variables partials.
ruby-on-rails ruby-on-rails-3
Comments
Post a Comment