[Rails] Re: Applying default conditions to a model's find, find_by_*
I originally used a with_scope, but that doesn't play nicely with will_paginate. On Feb 27, 3:14 pm, Maurício Linhares wrote: > At your model, override the find method: > > class SomeModel < ActiveRecord::Base > > class << self > > def find(*args) > with_scope( :conditions => {:property => 'value'} ) do > super(*args) > end > end > > end > > end > > - > Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) > |http://blog.codevader.com/(en) > > On Fri, Feb 27, 2009 at 5:11 PM, ericindc wrote: > > > Not at this point, so I'd prefer to come up with a solution using > > 2.2.2. > > > On Feb 27, 12:46 am, Craig Demyanovich wrote: > >> If you can move to Rails 2.3, which is currently in release candidate > >> testing, you could use default > >> scoping:http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-de... > > >> Regards, > >> Craig > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Applying default conditions to a model's find, find_by_*
At your model, override the find method: class SomeModel < ActiveRecord::Base class << self def find(*args) with_scope( :conditions => {:property => 'value'} ) do super(*args) end end end end - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Fri, Feb 27, 2009 at 5:11 PM, ericindc wrote: > > Not at this point, so I'd prefer to come up with a solution using > 2.2.2. > > On Feb 27, 12:46 am, Craig Demyanovich wrote: >> If you can move to Rails 2.3, which is currently in release candidate >> testing, you could use default >> scoping:http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-de... >> >> Regards, >> Craig > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Applying default conditions to a model's find, find_by_*
Not at this point, so I'd prefer to come up with a solution using 2.2.2. On Feb 27, 12:46 am, Craig Demyanovich wrote: > If you can move to Rails 2.3, which is currently in release candidate > testing, you could use default > scoping:http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-de... > > Regards, > Craig --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Applying default conditions to a model's find, find_by_*
If you can move to Rails 2.3, which is currently in release candidate testing, you could use default scoping: http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping Regards, Craig --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---