###前提・実現したいこと
Ruby on railsでdeviseを利用し、ユーザー登録・ログイン機能を作成しております。
ユーザー登録・ログインにおいて、「メールアドレス」ではなく、「Username」を用いたいと考えており、「メールアドレス」から「Username」に変更する作業を下記のサイト(補足情報に記載)をガイドに行いました。
しかし、「Email」の値を入力しているにも関わらずその値が認識されません。
具体的には下記のメッセージが表示されてしまいます。
対処方をご教示頂けませんでしょうか?
###発生している問題・エラーメッセージ
1.このように入力します。
###ソースコード:app>views>sessions>new.html.erb
ruby
1<h2>ログイン</h2> 2 3<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> 4 5 <div class="field"> 6 <%= f.label :username %><br /> 7 <%= f.text_field :username, autofocus: true %> 8 </div> 9 10 <div class="field"> 11 <%= f.label :email %><br /> 12 <%= f.email_field :email %> 13 </div> 14 15 <div class="field"> 16 <%= f.label :password %><br /> 17 <%= f.password_field :password, autocomplete: "off" %> 18 </div> 19 20 <% if devise_mapping.rememberable? -%> 21 <div class="field"> 22 <%= f.check_box :remember_me %> 23 <%= f.label :remember_me %> 24 </div> 25 <% end -%> 26 27 <div> 28 <%= f.submit "Sign in" %> 29 </div> 30 <% end %> 31 32 33 34 35 <div class="actions"> 36 <%= f.submit "Log in" %> 37 </div> 38 <% end %> 39 40 41<%= render "devise/shared/links" %> 42
###ソースコード:db>migrate>20160211163736_add_username_to_users.rb
ruby
1class AddUsernameToUsers < ActiveRecord::Migration 2 def change 3 add_column :users, :username, :string 4 add_index :users, :username, unique: true 5 end 6end 7
###app>views>devise>registrations>new.html.erb
ruby
1<h2>ユーザー登録</h2> 2 3<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 4 <%= devise_error_messages! %> 5 6 <div class="field"> 7 <%= f.label :username %><br /> 8 <%= f.text_field :username, autofocus: true %> 9 </div> 10 11 <div class="field"> 12 <%= f.label :email %><br /> 13 <%= f.email_field :email %> 14 </div> 15 16 <div class="field"> 17 <%= f.label :password %> 18 <% if @minimum_password_length %> 19 <em>(<%= @minimum_password_length %> characters minimum)</em> 20 <% end %><br /> 21 <%= f.password_field :password, autocomplete: "off" %> 22 </div> 23 24 <div class="field"> 25 <%= f.label :password_confirmation %><br /> 26 <%= f.password_field :password_confirmation, autocomplete: "off" %> 27 </div> 28 29 <div class="actions"> 30 <%= f.submit "Sign up" %> 31 </div> 32<% end %> 33 34<%= render "devise/shared/links" %> 35
###補足情報(言語/FW/ツール等のバージョンなど)
下記のサイトを参照しました。
http://ruby-rails.hatenadiary.com/entry/20140804/1407168000
お手数ですがよろしくお願い致します。以上
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/12 16:19
2016/02/12 16:32
2016/02/13 08:06