Lynda rubyonrailsチュートリアルをフォローしています。
これが私が実行しなければならないコードです"subject= Subject.new(:name =>" First Subject "、:position => 1、:visible => true)"
これは私のエラーメッセージです:
ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: name, position, visible
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activemodel-3.2.9/lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activemodel-3.2.9/lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal'
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activemodel-3.2.9/lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activemodel-3.2.9/lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/base.rb:497:in `initialize'
from (irb):9:in `new'
from (irb):9
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
これがモデルからの私のsubject.rbです:
class Subject < ActiveRecord::Base
# attr_accessible :title, :body, :name, :position, :visible
end