LoginSignup
15
13

More than 5 years have passed since last update.

deviseで確認パスワードを入れずに新規登録する方法

Posted at

デフォルトではpasswordpassword_confirmationの入力が必須です。
そこで、password_confirmationなしでの登録方法です。


model/user.rb
class User < ActiveRecord::Base
   attr_accessible :email, :password, :password_confirmation, :remember_me
end

とデフォルトではなっています。ここで、:password_confirmationを削除します。

views/registrations/new.html.erb
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>

  <div><%= f.label :last_name %><br>
  <%= f.text_field :last_name %></div>

  <div><%= f.label :first_name %><br>
  <%= f.text_field :first_name %></div>

  <div><%= f.label :email %><br />
  <%= f.email_field :email %></div>

  <div><%= f.label :password %><br />
  <%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation %></div>

  <div><%= f.submit "登録する" %></div>

<% end %>

ここでは、f.label :password_confirmationf.password_field :password_confirmationを削除します。

これで確認パスワードなしで新規登録することができます。

15
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
13