With your guidance, I have now seen named_scope work in my simple app by invoking it in an action! Thanks!
Hassan Schroeder wrote: > On Wed, Aug 12, 2009 at 12:24 PM, kevin > lee<[email protected]> 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 ------------------------ [email protected] > twitter: @hassan -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

