前提・実現したいこと
ここに質問の内容を詳しく書いてください。
Railsで自分の仮想通貨のアドレスを登録できるアプリケーションを作っています。
ツイッターログインをした後の、アドレスを早速登録して、Deviseで生成されたUserモデル(ethereum_addressというカラムを追加済)のethereum_addressにそのアドレスを挿入して更新する機能を実装中に以下のエラーメッセージが発生しました。
ActionView::Template::Error (undefined method `model_name' for true:TrueClass): 1: <h1>イーサリアムアドレスの登録</h1> 2: <!-- ここからフォーム --> 3: <%= form_for @address do |f| %> 4: <div class="field"> 5: <label>ご自身のイーサリアムアドレス</label><br> 6: <%= f.text_field :address %> app/views/pages/edit.html.erb:3:in `_app_views_pages_edit_html_erb__2336640512160563335_70299571723080' Started POST "/__web_console/repl_sessions/dfa4f6cf67affdff7e2b896853f062b2/trace" for 127.0.0.1 at 2018-06-27 21:38:56 +0900
該当のソースコード
/app/views/pages/edit.html.erb
Ruby
1 <h1>イーサリアムアドレスの登録</h1> 2 <!-- ここからフォーム --> 3 <%= form_for @address do |f| %> 4 <div class="field"> 5 <label>ご自身のイーサリアムアドレス</label><br> 6 <%= f.text_field :address %> 7 </div> 8 <div class="actions"> 9 <%= f.submit "登録",class:"btn btn-success" %> 10 </div> 11 <% end %> 12
/app/controllers/pages_controller.rb
Ruby
1class PagesController < ApplicationController 2 def index 3 if user_signed_in? 4 if current_user.ethereum_address.nil? == true 5 redirect_to pages_edit_path 6 else 7 redirect_to user_twitter_omniauth_authorize_path 8 end 9 end 10 end 11 def edit 12 if @address = current_user.update(ethereum_address: params[:address]) 13 current_user.save 14 else 15 redirect_to pages_index_path 16 end 17 end 18end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/27 13:01
2018/06/27 13:07
2018/06/27 13:09