Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何在一些数据之后进行迭代?_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 如何在一些数据之后进行迭代?

Ruby on rails 如何在一些数据之后进行迭代?,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 4,我有一个产品模型,有许多图像模型 在第一个循环中,我只得到了前4张图像 <% @product.images.first(4).each do |i| %> <li> <a href="<%= i.photo.url.to_s %>"> <%= image_tag(i.photo.url(:small).to_s, :class => 'thumbnail circle', :'data-zoom

我有一个产品模型,有许多图像模型

在第一个循环中,我只得到了前4张图像

 <%  @product.images.first(4).each do |i| %>
    <li>
      <a href="<%= i.photo.url.to_s %>">
        <%= image_tag(i.photo.url(:small).to_s, :class => 'thumbnail circle', :'data-zoom-href' => i.photo.url(:big).to_s) %>
      </a>
    </li>
       <% end %>

  • 如何在前4个图像之后循环其余图像?

    我试过这个:没有成功


    使用
    偏移量

    @product.images.offset(4).each { }
    

    offset(4)
    表示前4个之后的所有记录。

    尝试
    @product.images。分为(4)组。每个组都有| i |
    @product.images.offset(4).each { }