activerecord-hackery / meta_where

ActiveRecord 3 query syntax on steroids. Not currently maintained.
http://erniemiller.org/2013/11/17/anyone-interested-in-activerecord-hackery/
MIT License
588 stars 37 forks source link

How do I do a search through associations? #26

Open angelacode opened 13 years ago

angelacode commented 13 years ago

Here is what I tried:

http://stackoverflow.com/questions/6207545/how-do-i-search-through-associations-in-metawhere-in-rails-3

I read the following documentation and tried to follow it:

http://metautonomo.us/projects/metawhere/

Thanks! Just trying to make the translation of everything in my app....

angelacode commented 13 years ago

Here>is the error I get from Console:

  irb(main):002:0> Todo.joins(:contacts).where(:contacts => {:campaign_id => 1}).to_sql

NameError: undefined local variable or method `association' for #<ActiveRecord::Associations::ClassMethods::JoinDependency:0xb5433a54

franciscoj commented 13 years ago

Maybe something like that can fix your problem:

Todo.joins(:contacts).where(:contacts => [:campaign_id >> 1])

Disclaimer: I use MetaWhere.operator_overload!