Skip to content

Instantly share code, notes, and snippets.

@tonyc
Created December 2, 2015 00:39
Show Gist options
  • Save tonyc/ec6ae3425383b48fe28b to your computer and use it in GitHub Desktop.
Save tonyc/ec6ae3425383b48fe28b to your computer and use it in GitHub Desktop.
class User
has_one :plan
def has_feature?(name)
plan.has_feature? name
end
end
class Plan
has_many :line_items
def has_feature?(name)
line_items.find { |l| l.name.to_sym == name.to_sym }
end
end
class LineItem
# name:symbol
# cost_cents:integer
# whatever else
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment