A Feed has many Subscriptions
class Feed < ActiveRecord::Base
has_many :subscriptions
end
class Subscription < ActiveRecord::Base
belongs_to :feed, :counter_cache => true
belongs_to :user
end
This does not work
ch = Channel.find(:first)
ch.feeds.create(:user_id => 1, :score => 0.0)
user_id and score columns must be non-null, SQL INSERT sets them NULL.
Nor does it work with string keys instead of symbols.
This does:
ch = Channel.find(:first)
ch.feeds.create do |f|
f.user_id = 1
f.score = 0.0
end
According to AWDWR 1st and http://rails.rubyonrails.org/ both should
behave
the same. What has changed or I am doing wrong.
TIA,
Jeffrey