I have 2 models:
class Mission < ActiveRecord::Base
belongs_to :category
end
class Category < ActiveRecord::Base
has_many :missions
end
And I have a complex Mission find statement:
@missions = Mission.send(@view, level).send(@show).search(@search).paginate :page => params[:page], :order => actual_sort, :per_page => 50
I’d like to add to my query the possibility to search for a specific category too.
I tried this but it does not work:
@missions = Mission.send(@view, level).send(@show).send(:category, @category).search(@search).paginate :page => params[:page], :order => actual_sort, :per_page => 50
Rails says that Mission has not a .category method. How would you solve this?
Thanks,
Augusto
OH … MY … GOD
Are you sure this is the best way to be doing this?
I don’t think people will be able to help you if you don’t explain a bit more, but I highly doubt that you couldn’t write your statement like so:
Obviously the elipses (…) mean generally etc.
This is a working example on one of my projects in testing: