Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
13
Help us understand the problem. What is going on with this article?
@GenTamura84

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

More than 5 years have passed since last update.

デフォルトでは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を削除します。

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

13
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
GenTamura84
JavaScript / TypeScriptが好きです。 実家はVimです。VSCodeで出稼ぎしてます。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
13
Help us understand the problem. What is going on with this article?