end
{ :item_type
=> "Instrument"}, :order => :name)
I am getting Unknown column 'tools.item_type' even though item_type is
defined in the model. any ideas?
conditions need to reference database columns. methods you've defined
don't count.
:conditions => {'items.item_type' => 'Instrument'} should work.
Fred
ah ok thanks. since item_type isn't directly a database column but
item_type_id is i can get this statement working:
@tools = Tool.find(:all, :include => :item, :conditions =>
{'items.item_type_id' => 2}, :order => :name)
There's 2 separate things going on here. The first is including/joining the right tables (by the way, do you need :include or is :joins enough)
if you need to join item and then join item_types onto that then you need to do :include => {:item => :item_type}.
The second bit is the condition, where you just need to provide the disambiguated column name ie {'item_types.name' => 'Instrument'}