I have this code:
<% @cars.each do |car| %>
<div class="scroll-content-item ui-widget-header">
<%= link_to image_tag开发者_如何学编程( car.profile_avatar.asset.url(:thumb) ), car %>
</div>
<% end %>
..which will display the number of cars that are defined in the index
action:
def index
@search = Car.search(params[:search])
@cars = @search.all.paginate :page => params[:page], :per_page => 5
..so I'll have 5 images in the slider. I can't change it because I use it for the main <div>
.
The question is, how do I make another statement in the controller and how do I make a reference to it in the view so that I can have more car pictures in the slider? Thanks.
I got it.. I just add a new instance in controller like
@cars_footer = @search.all.paginate :page => params[:page], :per_page => 3
then I call it in the view with
<% @cars_footer.each do |car| %>
<div class="scroll-content-item ui-widget-header">
<%= link_to image_tag( car.profile_avatar.asset.url(:thumb) ), car %>
</div>
<% end %>
SO easy... well.. I am new in rails.
精彩评论