Skip to content

Instantly share code, notes, and snippets.

@canweriotnow
Created February 7, 2012 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canweriotnow/1762280 to your computer and use it in GitHub Desktop.
Save canweriotnow/1762280 to your computer and use it in GitHub Desktop.
Chaining scopes for milt
class Issue < ActiveRecord::Base
named_scope :tasks, :conditions => {:tracker_id => 7} # if the id of the Tasks tracker is 7, natch
named_scope :open, :conditions => {:status_id => 1} # assuming 'Open' == 1
end
# Then in your controller action:
@my_issue = Issue.open.tasks.find_by_assigned_to_id(User.current.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment