ssoushi0307
@ssoushi0307

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

ユーザー詳細画面でのユーザーの投稿の並び順を変える

解決したいこと

ユーザー詳細画面でのユーザーの投稿の並び順を変える

例)
Ruby on RailsでtwitterのようなWebアプリをつくっています。
投稿の並び順またorederが効きません
解決方法を教えて下さい。

該当するソースコード

def index
    @books = Book.all.order(created_at: :desc)
    @q = Book.ransack(params[:q])
    @books = @q.result
    @all_books = Book.all.order(created_at: :desc)
 end
<% @user.books.each do |book| %>
      <div class="posts-index-item">
        <div class="post-user-name">
          <%= link_to(book.user.name, "/users/#{book.user.id}",class: "link") %>
        </div>
        <div class=contents>
          <%= book.content %>
        </div>
        <div class="show">
          <%= link_to "Show this book", book ,class: "link"%>
        </div>
      </div>
<% end %>
0

No Answers yet.

Your answer might help someone💌