N
N
Nikita Filatov2016-03-14 13:25:16
Ruby on Rails
Nikita Filatov, 2016-03-14 13:25:16

How to solve the problem with unknown attribute for model error?

log with errors gives an error

ActiveRecord::UnknownAttributeError (unknown attribute 'category' for Entrant.)
I checked in the model whether there is such a field at all when creating Entrant.new this field is
<Entrant id: nil, name: nil, second_name: nil, profile: nil, project: nil, created_at: nil, updated_at: nil, category: nil>
This field was added via the AddCategoryToEntrant category:string migration. Therefore, when checking the controller, the params.require field is specified. The database also has this field.
Column    |            Type             |                       Modifiers                       
-------------+-----------------------------+-------------------------------------------------------
 id          | integer                     | not null default nextval('entrants_id_seq'::regclass)
 name        | character varying           | 
 second_name | character varying           | 
 profile     | character varying           | 
 project     | character varying           | 
 created_at  | timestamp without time zone | not null
 updated_at  | timestamp without time zone | not null
 category    | character varying           |
in general, I'm waiting for help, because I no longer know where the problem could be. The problem appeared after the project was rolled out to production, everything is fine on the local host.
schema.rb also has a category

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question