我有一个从数据库迁移创建的表:
class CreateTickets < ActiveRecord::Migration
def up
create_table :tickets, :primary_key => :tickets_id do |t|
t.string :title, null: false
t.text :body
t.datetime :create_date
t.integer :author_id
t.integer :status, null: false, default: 0
end
end
一个模型:
class Ticket < ActiveRecord::Base
attr_accessible :title, :body, :create_date, :author_id, :status
end
当我尝试创建记录时:
User.create(title: title,body: body,create_date: Time.zone.now, author_id: @author_id,status: 0)
我收到此错误:
无法批量分配受保护的属性:title、body、create_date、author_id、status
我做错了什么?