Module: Bento::Models::User
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/bento/models/user.rb
Instance Method Summary collapse
Instance Method Details
#fake_belongs_to(singular) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bento/models/user.rb', line 4 def fake_belongs_to(singular) singular = singular.to_s plural = singular.pluralize define_method(singular) do send(plural).first end define_method("#{singular}=") do |record| send(plural).each(&:destroy) self.send(plural) << record end end |