简体   繁体   中英

Ruby on Rails: undefined method 'role' for Class

I'm haing a problem in my Ruby on Rails application. I have an entity called 'Hairdresser', with those properties:

irb(main):003:0> Hairdresser
=> Hairdresser(id: integer, name: string, surname: string, email: string, auth_token: string, password_digest: string, created_at: datetime, updated_at: datetime, facebook_id: string, first_login: boolean, role: string)

I also created some scaffold in order to create new Hairdresser entities, but when I click on "new hairdresser" I get the following error:

2016-03-17T09:14:43.063793+00:00 app[web.1]: ActionView::Template::Error (undefined method `role' for #<Hairdresser:0x007f9e20f2bc30>):
2016-03-17T09:14:43.063794+00:00 app[web.1]:     25:   </div>
2016-03-17T09:14:43.063794+00:00 app[web.1]:     26:   <div class="field">
2016-03-17T09:14:43.063795+00:00 app[web.1]:     27:     <%= f.label :role %><br>
2016-03-17T09:14:43.063795+00:00 app[web.1]:     28:     <%= f.text_field :role %>
2016-03-17T09:14:43.063795+00:00 app[web.1]:     29:   </div>

Role is a property that I added AFTER the creation of the scaffold, but I also added it where it was supposed to be added (I think):

view/hairdressers/_form.html.erb

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

view/hairdressers/index.html.erb, index.json.jsonbuilder, and in every other /view/hairdressers file.

The local version of the application is working, it could have something to do with the fact that Heroku is loading the production environment and on localhost I am running the development environment?

EDIT: this is the execution of heroku run rake --trace db:migrate

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
  ActiveRecord::SchemaMigration Load (0.8ms)  SELECT "schema_migrations".* FROM "schema_migrations"
** Invoke db:_dump (first_time)
** Execute db:_dump

Make sure the migrations are run on heroku. https://devcenter.heroku.com/articles/rake

heroku run rake --trace db:migrate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM