質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

0回答

2816閲覧

NoMethodError in Devise::Registrations#new のエラー

sairito0628

総合スコア15

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2019/02/28 21:28

何回試してもこのようなエラーが出てしまいます。
初めたばかりで失礼がありましたら申し訳あません。

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">
<%= f.label :name %><br /> <%= f.text_field :name, autofocus: true, autocomplete: "name" %>
</div>
ちなみに、マイグレーションファイルはこちらになります 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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2019/03/01 00:37

schema.rbのcreate_tableを見せていただけますか?
sairito0628

2019/03/01 08:57

こちらになります。。。 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
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問