Keep getting unidentified method 'field' for undefined method `bio' for #<User:>

馋奶兔 提交于 2019-12-25 07:24:02

问题


I just deployed my app to Heroku and I'm facing this problem. In the sign up page:

<div class="field">
    <%= f.label :bio %><br />
    <%= f.text_field :bio %>
  </div>

and in the logs

ActionView::Template::Error (undefined method `bio' for #<User:0x007f5e772493c0>):
<div class="field">
        <%= f.label :bio %><br />
        <%= f.text_field :bio %>
      </div>

Any thoughts on this? Thanks Ps. used to work fine before deployment

EDIT

I tried to migrate but I got this error

Couldn't create database for {"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/test.sqlite3"}
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

回答1:


You haven't run the migrations thats why its unable to find the column :bio for user.

Run this command on your console

heroku run rake db:migrate


来源:https://stackoverflow.com/questions/39500282/keep-getting-unidentified-method-field-for-undefined-method-bio-for-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!