Hi, I want to limit the scope of records for a ActiveRecord class. class Product < ActiveRecord::Base end I can use with_scope to limit the result set. However, I want to limit it in the model in a fixed way so that with_scope rule is implicitly forced. For example, class Product < ActiveRecord::Base with_scope :find => {:conditions = "created_at > ''2000-01-01''"} end How can I accomplish that? Thanks in advance. Sam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mitchell James
2007-Nov-29 19:16 UTC
Re: How to embed with_scope in ActiveRecord class defnition?
http://railscasts.com/episodes/5 -- James Mitchell On Nov 29, 2007, at 2:13 PM, Sam Kong wrote:> > Hi, > > I want to limit the scope of records for a ActiveRecord class. > > class Product < ActiveRecord::Base > end > > I can use with_scope to limit the result set. > However, I want to limit it in the model in a fixed way so that > with_scope rule is implicitly forced. > > For example, > > class Product < ActiveRecord::Base > with_scope :find => {:conditions = "created_at > ''2000-01-01''"} > end > > How can I accomplish that? > > Thanks in advance. > > Sam > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---