Probably a silly question, so I apologize in advance for this:
I have an Item Controller
whose index action I'm using to show all items
(duh). Now, I want to filter the items that are shown (here, just ones that have 'shoes' in their titles).
Unfortunately, I am not able to define the @item = Item.find(params[:id]) statement under the index action.
I am getting the dreaded ActiveRecord::RecordNotFound in ItemsController#index ---- Couldn't find Item without an ID error.
Any ideas?
Items Controller
def index
@item = Item.find(params[:id])
@items = Item.where(@item.title =~ /shoes/i).paginate(:page => params[:page], :per_page => 30)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @items }
end
end