2

I currently have a users page which displays all the reviews that user has written. Each review is displayed as a partial (named _profile) and they are all shown on a page of an accordian. How can I add pagination to these review partials?

users show page

<div class="profile_reviews_container">
  <div id="accordion">
    <h3><a href="#">Reviews written</a></h3>
    <div class="profile_reviews_cont">
      <% @user.reviews.each do |review| %>
        <%= render "reviews/profile", :profile => review %>
      <% end %>
    </div>

    <h3><a href="#">Favourites</a></h3>
    <div>
    </div>
  </div>
</div>

Which controller do I add the .paginate call to and will the view contain <%= will_paginate @reviews %> or <%= will_paginate @profiles %>?

Thanks for any help its much appreciated!

4

1 に答える 1

4

Users#show アクションでレビューをページ付けします。何かのようなもの:

@reviews = @user.reviews.paginate page: params[:page]

そして、次のように呼び出します。

<%= will_paginate @reviews %>

ビューで。

また、パーシャルの名前を変更 (または新しいものを作成) してreviews/_review、次のように呼び出すことができます。

<%= render @reviews %>

しかし、それは私です。

于 2011-07-01T02:24:00.410 に答える