Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ActiveRecord::Base
- has_many :device_ownerships
- has_many :devices, :through => :device_ownerships
- class Device < ActiveRecord::Base
- has_one :device_ownership
- has_one :user, :through => :device_ownership
- end
- class DeviceOwnership < ActiveRecord::Base
- belongs_to :user
- belongs_to :device
- end
- def create
- user = User.create
- device = Device.create
- device_ownership = DeviceOwnership.create(:serial_numer => params[:device_serial_number], :device_id => device.id, :user_id => user.id)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement