Reputation: 165
I'm a rails newbie and I'm trying to construct a feed of posts that are pulled from the database based on the characteristic of a category (in this case music). The action getting flagged is:
def music
@music_wads = Wad.find_by(category: "Music").paginate(page: params[:page])
end
Perhaps I'm making an error with the syntax, but I have the gem will_paginate installed. I have yet to actually add the <%= will_paginate @music_wads %> to my view however. Any thoughts?
Upvotes: 1
Views: 615
Reputation: 1407
Try .where
instead of .find_by
:
@music_wads = Wad.where(category: "Music").paginate(page: params[:page])
.find_by
returns first record matching your conditions, while .paginate
needs an ActiveRecord::Relation
collection of records to work.
Upvotes: 1