Nested Model Mass Assignment Error

Hi,

I have a many-to-many relationship via a join table. When I attempt to set the values (i.e. the relationship) in the join table via the Rails console I get the following error, does anyone know what could be wrong? Thanks.

Note: I have set attr_accessible -- see Grade model below.

ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: id, grade_salary_attributes_attributes

In the Rails console I execute:

grade = Grade.find(:first)

params = {:grade => { :id => 1, :grade_salary_attributes_attributes => { :id => 1, :grade_id => 1, :salary_attribute_id => 2 }}}

grade.update_attributes(params[:grade])

Below are the 3 models:

**Grade Model**

class Grade < ActiveRecord::Base   has_many :grade_salary_attributes   has_many :salary_attributes, :through => :grade_salary_attributes

  accepts_nested_attributes_for :grade_salary_attributes, :reject_if => lambda {|attributed| attributed['grade_id'].nil? || attributed['salary_attribute_id'].nil?}

  attr_accessible :description, :title, :grade_salary_attributes_attributes end

**Salary Attribute Model**

class SalaryAttribute < ActiveRecord::Base   has_many :grade_salary_attributes   has_many :grades, :through => :grade_salary_attributes

  attr_accessible :description, :title end

**Grade Salary Attribute (Join) Model**

class GradeSalaryAttribute < ActiveRecord::Base   belongs_to :grade   belongs_to :salary_attribute

  attr_accessible :grade_id, :salary_attribute_id end