If this happens to you:
user.avatar = Avatar.new
user.avatar # => nil
(where avatar
is a belongs_to
), you probably declared your association incorrectly.
Always do
class User < ActiveRecord::Base
belongs_to :avatar
end
and never
class User < ActiveRecord::Base
belongs_to 'avatar'
end
Posted by Tobias Kraze to makandra dev (2012-09-25 12:35)