我创建了一个迁移并运行rake db:migrate
,但它说它不在那里。在我的IDE中,它不会给我一个错误,但也不会将其保存在数据库中。它给了我关于Heroku上的生产版本的错误。
模式
create_table "reviews", force: :cascade do |t|
t.string "name"
t.text "description"
t.integer "rating"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "pros"
t.text "cons"
t.string "category"
end
表单,视图:https://hastebin.com/otisoqibon.js
<div class="field">
<p class="flow-text">Category</p>
<%= f.text_field :category, :class => "grey lighten-2 autocomplete", :id => "autocomplete-input", %>
</div>
控制器
def new
@review = Review.new
end
错误
- 2017-04-20T01:49:22.051420+00:00 app[web.1]:
ActionView::Template::Error (undefined method `category' for ):
- 2017-04-20T01:49:22.051421+00:00 app[web.1]: 17: </div>
- 2017-04-20T01:49:22.051423+00:00 app[web.1]: 19: <p class="flow-text">Category</p>
- 2017-04-20T01:49:22.051422+00:00 app[web.1]: 18: <div class="field">
- 2017-04-20T01:49:22.051424+00:00 app[web.1]: 20: <%= f.text_field :category, :id => "autocomplete-input", :class => "grey
lighten-2 autocomplete" %>
- 2017-04-20T01:49:22.051424+00:00 app[web.1]: 21: </div>
- 2017-04-20T01:49:22.051425+00:00 app[web.1]: 22: <div class="field">
- 2017-04-20T01:49:22.051426+00:00 app[web.1]: 23: <p class="flow-text">Pros, Woof Woof</p><br>
答案 0 :(得分:1)
我想那是因为你在heroku上没有运行你的rake db:migrate任务。
heroku run rake db:migrate