You can probably override the find method and use with_scope
class Function < ActiveRecord::Base
def self.find(*args)
with_scope(:find => { :conditions => ''lft > 0'',
:order => ''lft'' }) do
super
end
end
end
-Jonathan.
On 6/3/06, Ryan.S.Warner@seagate.com <Ryan.S.Warner@seagate.com>
wrote:>
> Is there a way to provide "sticky" options to
ActiveRecord::Base::Find ?
>
> I''m thinking something with a use model like:
>
> class Function < ActiveRecord::Base
> sticky :conditions => "lft > 0", :order => "lft
ASC"
> end
>
> Where all subsuquent find operations have those options applied. In this
> case:
>
> Function.find(:all)
>
> Would actually be equivalent to:
>
> Function.find(:all, :conditions => "lft > 0", :order =>
"lft ASC")
>
> And
>
> Function.find(:all, :conditions => "parent_id = 0")
>
> Would actually be equivalent to:
>
> Function.find(:all, :conditions => "lft > 0 AND parent_id =
0", :order =>
> "lft ASC")
>
> Thanks,
> Ryan
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>