Method: WhalesORM::Associatable#has_many
- Defined in:
- lib/associatable.rb
#has_many(name, options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/associatable.rb', line 54 def has_many(name, = {}) if [:through] has_one_or_many_through(name, [:through], [:source]) else opts = WhalesORM::HasManyOptions.new(name.to_s, self.to_s, ) define_method(name) do primary_key_value = send(opts.primary_key) where_clause = {opts.foreign_key => primary_key_value} opts.model_class.where(where_clause) end [name] = opts end end |