有一个问题在这里与jobs_controller.rb,当我从我下面的job.rb模型去除设计模块:的ActiveRecord :: StatementInvalid在JobsController#创建
class Job < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :contact_email, :contact_phone, :description, :district, :due_date, :expiration_date, :job_title, :posting_date, :requirements, :salary, :submission_process
end
我然后取下设计模块,并在到达结果模型:
class Job < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :contact_email, :contact_phone, :description, :district, :due_date, :expiration_date, :job_title, :posting_date, :requirements, :salary, :submission_process
end
在作出这一转变显示在下面的跟踪抛出的错误:
ActiveRecord::StatementInvalid in JobsController#create
SQLite3::ConstraintException: constraint failed: INSERT INTO "jobs" ("contact_email", "contact_phone", "created_at", "current_sign_in_at", "current_sign_in_ip", "description", "district", "due_date", "email", "encrypted_password", "expiration_date", "job_title", "last_sign_in_at", "last_sign_in_ip", "posting_date", "remember_created_at", "requirements", "reset_password_sent_at", "reset_password_token", "salary", "sign_in_count", "submission_process", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
app/controllers/jobs_controller.rb:49:in `block in create'
app/controllers/jobs_controller.rb:48:in `create'
我有一个用户模型以及一个工作模型,应用程序由一个基本的脚手架组成,允许用户发布和查看作业,这取决于与Devise的正确认证。我对于正确的后端构建相对陌生,并且对前端视图类型的Rails有更多的经验。我不知道我是否需要在Job模型中存在Devise,或者只在User模型中。