有一個問題在這裏與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模型中。