Sha256: 4e6a4dfc15e388f9c99185e49a4e28c253f0eb77c7d19646fecb83a96302e763

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 Bytes

Contents

require 'bundler/setup'
require 'super_model'

class User < SuperModel
  
  has_one :photo
  has_many :photos
  
end

class Photo < SuperModel
  
  belongs_to :user
  
end


p1 = Photo.new
p2 = Photo.new

u = User.new( photo: p1, photos: [p1, p2] )

p u.photo.user

p u.photo == p1

u.photo_id = p2.object_id # TODO: Wait.. this is wrong.. the BelongsTo association holds the ASSOCIATION_id methods....

p u.photo == p2

p u.photos

u.photos = [p1, p2]

p u.photos

p u.photo_ids

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
super_model-0.0.1 examples/associations_example.rb