I keep getting an error undefined method where
when running the code below with these parameters.
Can anyone see what I'm doing wrong?
Thanks
Parameters: {"category_ids"=>["1", "3", "4"]}
@pieces = Piece.all
@pieces = @pieces.where(:category_id => params[:category_ids]) if params[:category_ids].present?
@pieces = @pieces.where(:brand_id => params[:brand_ids]) if params[:brand_ids].present?
@pieces = @pieces.where(:color_id => params[:color_ids]) if params[:color_ids].present?
@pieces = @pieces.where(:user_id => params[:friend_ids]) if params[:friend_ids].present?
It should be:
Piece.where(:category_id => params[:category_ids]) if params[:category_ids].present?