On Wed, Aug 12, 2009 at 12:24 PM, kevin lee<rails-mailing-l...@andreas-s.net> wrote: > > I have generated a simple event app to learn and try to debug > named_scope. But still have problem. My problem is still have not > figure out how to call the named_scope (i.e. Event.upcoming).
Ex: named_scopes in a model: named_scope :mode, lambda { |mode| { :conditions => ['mode = ?', mode] } } named_scope :available, lambda { |current_user| { :conditions => [ " permission = ? OR user_id = ?" , 'public', current_user.id ] } } :: and in the controller: @notes = Note.available(current_user).mode params[:mode] :: which also demonstrates scope chaining, FWIW. HTH, -- Hassan Schroeder ------------------------ hassan.schroe...@gmail.com twitter: @hassan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---