Keep getting unidentified method 'field' f

2019-09-04 05:51发布

问题:

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