Your SlideShare is downloading. ×
0
Rails: has_many vs has_one
Rails: has_many vs has_one
Rails: has_many vs has_one
Rails: has_many vs has_one
Rails: has_many vs has_one
Rails: has_many vs has_one
Rails: has_many vs has_one
Rails: has_many vs has_one
Rails: has_many vs has_one
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Rails: has_many vs has_one

2,132

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,132
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide









  • Transcript

    • 1. has_many vs has_one 2010/10/02 Shouichi KAMIYA
    • 2. Given class App ActiveRecord::Base has_many :servers end class Server ActiveRecord::Base belongs_to :app end
    • 3. Then irb> app = App.new irb > app.servers = [Server.new] irb > app.servers #=> [#<Server:0x101141d68>]
    • 4. Looking good.
    • 5. Given class App ActiveRecord::Base has_one :server end class Server ActiveRecord::Base belongs_to :app end
    • 6. Then irb> app = App.new irb > app.server = Server.new irb > app.server #=> nil
    • 7. What!?
    • 8. The correct way irb> app = App.new irb > app.set_server_target = Server.new irb > app.server #=> #<Server:0x101141d68>
    • 9. WTF... Thanks!

    ×