Ruby on rails 创建了新列,但我仍然得到NoMethodError/undefined方法
以下是完整的错误:Ruby on rails 创建了新列,但我仍然得到NoMethodError/undefined方法,ruby-on-rails,Ruby On Rails,以下是完整的错误: Failure/Error: project = Factory.create(:question, :title => "How much does a wood chuck?") NoMethodError: undefined method `title=' for #<Question:0x007fe38caad1c0> # ./spec/integration/creating_questio
Failure/Error: project = Factory.create(:question, :title => "How much does a wood chuck?")
NoMethodError:
undefined method `title=' for #<Question:0x007fe38caad1c0>
# ./spec/integration/creating_questions_spec.rb:15:in `block (2 levels) in <top (required)>'
然后我迁移了数据库。这是我的schema.rb
ActiveRecord::Schema.define(:version => 20130714164611) do
create_table "questions", :force => true do |t|
t.string "post"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "title"
end
end
在我的模型中:
class Question < ActiveRecord::Base
attr_accessible :post
end
类问题
我尝试将“title”添加到我的模型中,以查看它是否修复了它,但仍然得到相同的错误。任何想法
修复了它:
最后,我硬重置到以前的提交,并再次创建新列。它现在可以工作了,我不确定以前出了什么问题。试着运行rake db:test:prepare,看看是否有效。试着运行rake db:test:prepare,看看是否有效
class Question < ActiveRecord::Base
attr_accessible :post
end