{"id":670,"date":"2012-08-09T13:06:33","date_gmt":"2012-08-09T04:06:33","guid":{"rendered":"http:\/\/www.whoocus.com\/blog\/?p=670"},"modified":"2013-06-01T08:59:11","modified_gmt":"2013-05-31T23:59:11","slug":"rails-%e6%a4%9c%e8%a8%bc%e6%a9%9f%e8%83%bd-confirmation-%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/www.blowfish.co.jp\/?p=670","title":{"rendered":"Rails \u691c\u8a3c\u6a5f\u80fd :confirmation \u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>Rails3 \u306b\u3066\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u7b49\u306e\u518d\u5165\u529b\u306e\u30d5\u30a9\u30fc\u30e0\u304c\u3042\u308b\u304c\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u305f\u304c\u3001\u3069\u3046\u3057\u3066\u3082 :confirmation => true \u306e\u5165\u529b\u691c\u8a3c\u304c\u52b9\u304b\u306a\u3044\u3002<\/p>\n<p>login.html.erb<br \/>\n[ruby]<br \/>\n&lt;%= text_field_tag :email, nil, {:placeholder =&gt; &quot;\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9&quot;}%&gt;<br \/>\n&lt;%= password_field_tag :password, nil, {:placeholder =&gt; &quot;\u30d1\u30b9\u30ef\u30fc\u30c9&quot;}%&gt;<br \/>\n&lt;%= password_field_tag :password_confirmation, nil, {:placeholder =&gt; &quot;\u78ba\u8a8d\u30d1\u30b9\u30ef\u30fc\u30c9&quot;}%&gt;<br \/>\n[\/ruby]<\/p>\n<p>member.rb<br \/>\n[ruby]<br \/>\nclass Member &lt; ActiveRecord::Base<br \/>\n  #<br \/>\n  # \u691c\u8a3c\u6a5f\u80fd<br \/>\n  #<br \/>\n  validates :email,<br \/>\n            :presence =&gt; true,<br \/>\n            :uniqueness =&gt; true<br \/>\n  validates :password,<br \/>\n            :presence =&gt; true,<br \/>\n            :confirmation =&gt; true<br \/>\nend<br \/>\n[\/ruby]<\/p>\n<p>\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u3001controller\u30af\u30e9\u30b9\u5185\u306e\u8a18\u8ff0\u304c\u307e\u305a\u304b\u3063\u305f\u3088\u3046\u3060\u3002\u5b9f\u969b\u3001\u4e0a\u8a18\u306emodel\u30af\u30e9\u30b9\u3068View\u306e\u8a18\u8ff0\u306b\u306f\u9593\u9055\u3044\u304c\u306a\u3044\u3002<\/p>\n<p>\u554f\u984c\u70b9\u306f\u3001@member.password_confirmation \u306e\u90e8\u5206\u3092\u8a18\u8ff0\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u3053\u3068\u3060\u3002<\/p>\n<p>\u691c\u8a3c\u6a5f\u80fd\u306f\u3001save\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u305f\u6642\u306b\u6a5f\u80fd\u3059\u308b\u3089\u3057\u3044\u3002<br \/>\n@member\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306b\u3001password_confirmation\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u306a\u3044\u70ba\u306b\u3001\u3046\u307e\u304f\u52d5\u4f5c\u3057\u306a\u304b\u3063\u305f\u3088\u3046\u3060\u3002<\/p>\n<p>register_controller.rb<br \/>\n[ruby]<br \/>\n  def register<br \/>\n    @member = Member.new<br \/>\n    @member.email = params[:email]<br \/>\n    @member.password = params[:password]<br \/>\n    # \u3053\u306e\u90e8\u5206\u306e\u8a18\u8ff0\u6f0f\u308c<br \/>\n    # \u2193 \u2193 \u2193 \u2193 \u2193<br \/>\n    @member.password_confirmation = params[:password_confirmation] <\/p>\n<p>    if @member.save<br \/>\n      #\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u30bb\u30c3\u30b7\u30e7\u30f3\u767b\u9332<br \/>\n      redirect_to index_path<br \/>\n    else<br \/>\n      reset_session<br \/>\n      redirect_to error_path<br \/>\n    end<br \/>\n  end<br \/>\n[\/ruby]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rails3 \u306b\u3066\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u7b49\u306e\u518d\u5165\u529b\u306e\u30d5\u30a9\u30fc\u30e0\u304c\u3042\u308b\u304c\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u305f\u304c\u3001\u3069\u3046\u3057\u3066\u3082 :confirmation => true \u306e\u5165\u529b\u691c\u8a3c\u304c\u52b9\u304b\u306a\u3044\u3002 login.html.erb [ruby] &lt;%= [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[25,14,4],"tags":[],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-rails","category-ruby","category-tech"],"_links":{"self":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=670"}],"version-history":[{"count":2,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":1571,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions\/1571"}],"wp:attachment":[{"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blowfish.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}