I’m very new at rails. I’m making a simple blog made up of entries. I
have an entry model and a category model. Obviously, each category will
have many entries, and each entry will be in a category.
I have a select box that submits a category_id to my controller. How
can I use this category_id to only show entries that have that
category_id?
Here’s what I have so far, which just returns nothing:
def list @entry_pages, @entries = paginate :entries, :per_page => 10,
:order_by => ‘date desc’ @categories = Category.find_all
end
Try trying changing params[:entry] to params[:entry][:category_id].
Just to note, it’s probably best to not use form_for in this instance
as you are not dealing directly with a model. I would rework this to
something like this: