Created
November 9, 2012 16:05
-
-
Save davetapley/4046513 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Normal has_many / belongs_to: | |
>> a = c.permitted_ips | |
=> [] | |
# What we got back was just an Array: | |
>> a.class | |
=> Array | |
# Now build a new record: | |
>> c.permitted_ips.build :address => '123123' | |
=> #<PermittedIp id: nil, client_id: 14, description: nil, address: "123123", created_at: nil, updated_at: nil> | |
# All makes sense so far | |
# But now let's check `a` is still `[]`: | |
>> a | |
=> [#<PermittedIp id: nil, client_id: 14, description: nil, address: "123123", created_at: nil, updated_at: nil>] | |
# How has that happened? (`a` appears to have re-evaluated itself), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment