Home>
Please write your question in detail here.
(Example) I am making a ●● system with PHP (CakePHP).
The following error message occurred while implementing the ■■ function.
User.create! (name: 'admin', email: '[email protected]', password: 'password', password_confirmation: 'password', admin: true)</code></pre >
<strong>Error message</strong>
<pre><code data-language = "terminal">ActiveModel :: UnknownAttributeError: unknown attribute 'admin' for User.
from /Users/user/rails/taskleaf/vendor/bundle/ruby/2.6.0/gems/activemodel-5.2.3/lib/active_model/attribute_assignment.rb:53:in `_assign_attribute '
Applicable source code
Rails.application.routes.draw do
namespace: admin do
resources: users
end
root to: 'tasks # index'
resources: tasks
get '/ login', to: 'sessions # new'
post '/ login', to: 'sessions # create'
delete '/ logout', to: 'sessions # destroy'
end
app/controllers/admin/users_contriller.rb
class Admin :: UsersController</pre>
<strong>schema.rb</strong>
<pre><code># This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema.If i need to create the application database on another
# system, you should be using db: schema: load, not running all the migrations
# from scratch.The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord :: Schema.define (version: 2019_11_28_035704) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "tasks", force:: cascade do | t |
t.string "name", limit: 30
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id", null: false
t.index ["user_id"], name: "index_tasks_on_user_id"
end
create_table "users", force:: cascade do | t |
t.string "name", null: false
t.string "email", null: false
t.string "password_digest", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_users_on_email", unique: true
end
end
$bundle list | grep bcrypt
* bcrypt (3.1.13)
Supplemental information (FW/tool version etc.)
Please provide more detailed information here.
-
Answer # 1
Related articles
- ruby on rails 6 - i get activemodel :: unknownattributeerror in actiontext
- ruby on rails - activemodel :: unknownattributeerror in production environment
- ruby - about "activemodel :: unknownattributeerror" of rails
- ruby - many-to-many post tag search mysql2 :: error: unknown column i want to solve'poststag_ids' in'where clause'
- ruby - [rails] the class attribute specified by the div tag enclosed in simple_format is not applied
- ruby - [rails] i want to create a link including the data attribute with the link_to helper
- ruby on rails - about passing the attribute of ror class as an argument
- ruby - i want to resolve mysql2 :: error :: connectionerror (unknown mysql server host'db' (0)): that occurred while deploying t
- ruby - i want to avoid the mysql2 :: error: unknown table'likes' error that appears when deploying to heroku
- ruby - rails activemodel :: forbiddenattributeserror does not occur
- ruby on rails - unknown action error when trying to post a comment
- ruby - i want to get all rails staff activemodel :: serializer
- ruby on rails - unknown mysql server host'db' (0) error persists
- ruby on rails - [rails 6] an error may or may not occur [unknown validator/active storage]
Related questions
- ruby - passing variables using render partial
- ruby - i would like to know how to realize what is written in smarthr's blog
- ruby - i installed carrierwave with rails, but i can't see the image
- ruby - about rails controller new action
- ruby - rails page does not open
- [ruby] i'm having trouble with nomethoderror
- ruby - [search function] acquisition of products associated with users
- ruby - even if each statement is used, the contents of the db cannot be displayed in order and an error occurs
- ruby - if i include the'omniauth-facebook'gem, do i need to install the'omniauth' gem as well?
- ruby - unable to open rails server
Use
bin/rails db: rollback
to restoreadd_admin_to_users.rb
before executingbin/rails db: migrate
please.