Let us take an example:
class Subscription < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :subscriptions
end
u1 =User.new
s1 = Subscription.new
According to me, the following two lines should be equivalent:
u1.subscriptions << s1, and
s1.user = u1
However, it seems that it is not the case. After executing the first line, u1.subscriptions_ids returns [1] but after executing the second line, u1.subscriptions_ids returns [].
What could be the reason for this?