Association proxy create

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

It's possible that the attributes aren't getting assigned because they're protected. Do you have attr_protected or attr_accessible declared anywhere in your model?

This is on Rails 2.3.2.

Quoting Jeffrey L. Taylor <ror@abluz.dyndns.org>:

Pat,   Head slap, yes that is precisely the problem. Thanks for seeing into my blind spot.

Jeffrey

Quoting Pat Nakajima <patnakajima@gmail.com>:

It's possible that the attributes aren't getting assigned because they're protected. Do you have attr_protected or attr_accessible declared anywhere in your model?

[snip]