何回試してもこのようなエラーが出てしまいます。
初めたばかりで失礼がありましたら申し訳あません。
Showing /home/ec2-user/environment/Bookers/app/views/devise/registrations/new.html.erb where line #7 raised:
undefined method `name' for #<Rio id: nil, email: "", created_at: nil, updated_at: nil>
```
<div class="field"></div><%= f.label :name %><br /> <%= f.text_field :name, autofocus: true, autocomplete: "name" %>
ちなみに、マイグレーションファイルはこちらになります t.string :nameを追加した後、 $rails db:migrateはしました。
class DeviseCreateRios < ActiveRecord::Migration[5.2]
def change
create_table :rios do |t|
## Database authenticatable #メールアドレス t.string :email, null: false, default: "" #暗号化されたパスワード t.string :encrypted_password, null: false, default: "" ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token # t.datetime :confirmed_at # t.datetime :confirmation_sent_at # t.string :unconfirmed_email # Only if using reconfirmable ## Lockable # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts # t.string :unlock_token # Only if unlock strategy is :email or :both # t.datetime :locked_at t.string :name t.timestamps null: false end add_index :rios, :email, unique: true add_index :rios, :reset_password_token, unique: true # add_index :rios, :confirmation_token, unique: true # add_index :rios, :unlock_token, unique: true
end
end
schema.rbのcreate_tableを見せていただけますか?
こちらになります。。。
ActiveRecord::Schema.define(version: 2019_02_28_191757) do
create_table "rios", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_rios_on_email", unique: true
t.index ["reset_password_token"], name: "index_rios_on_reset_password_token", unique: true
end
end
あなたの回答
tips
プレビュー