But it generates an html repeating @picks over and over again until
the
page is full.
Am I missing any parameter here so it behaves like this?
Any help are highly appreciated.
Change it to:
_pick.rhtml
The :collection part of the render implies the loop “for pick in @picks” (actuallly, the @picks comes from the :collection and the
‘pick’ from the :partial).
And you probably should use link_to(image_tag(…), …) as
previously suggested.
def index @picks =Product.find_person(session[:user_id])
#@[email protected] @picks.sort_by{|x| x.id}.reverse
render :partial => “pick”, :collection => @picks
end
And to possibly save you your next message, @picks.sort_by{|x| x.id}.reverse
doesn’t change @picks.
Perhaps you want:
def index @picks =Product.find_person(session[:user_id]).sort_by {|p| - p.id }
render :partial => “pick”, :collection => @picks
end
Note the use of ‘- p.id’ to reverse the order in one step. It also
seems odd (to me at least) that “find_person” returns more than one
object since it is singular; “find_people” might be clearer. Of
course, that just makes me wonder why the Product model is finding a
Person at all.