{"id":201,"date":"2014-02-03T18:44:26","date_gmt":"2014-02-03T09:44:26","guid":{"rendered":"http:\/\/lovelinux.mydns.jp\/?p=201"},"modified":"2014-03-21T17:41:20","modified_gmt":"2014-03-21T08:41:20","slug":"devise%e3%81%ae%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e7%99%bb%e9%8c%b2%e6%99%82%e3%81%ab%e3%80%81%e7%8b%ac%e8%87%aa%e3%81%ae%e5%87%a6%e7%90%86%e3%82%92%e8%bf%bd%e5%8a%a0%e3%81%99%e3%82%8b%e3%80%82","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=201","title":{"rendered":"Devise\u306e\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u306b\u3001\u72ec\u81ea\u306e\u51e6\u7406\u3092\u8ffd\u52a0\u3059\u308b\u3002"},"content":{"rendered":"<p>Rails\u306e\u8a8d\u8a3c\u51e6\u7406\u306bdevise\u3092\u7528\u3044\u3066\u3044\u308b\u5834\u5408\u3001\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u306e\u767b\u9332\u306f\u81ea\u52d5\u7684\u306b\u884c\u308f\u308c\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306fUsers\u30c6\u30fc\u30d6\u30eb\u306b\u8a2d\u5b9a\u3057\u305femail\u3068password\u304c\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u3053\u308c\u3067OK\u306a\u306e\u3067\u3059\u304c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4ed5\u69d8\u4e0a\u3001\u30e6\u30fc\u30b6\u30fc\u3092\u65b0\u898f\u306b\u8ffd\u52a0\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u5225\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3057\u305f\u3044\u30b1\u30fc\u30b9\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u305d\u3093\u306a\u30b1\u30fc\u30b9\u306b\u5bfe\u5fdc\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>devise\u306e\u30bd\u30fc\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3068 RegistrationsController\u306e create\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u767b\u9332\u51e6\u7406\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002\u3067\u3059\u306e\u3067\u3001\u4eca\u56de\u306f\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3066\u3001\u8ffd\u52a0\u306e\u51e6\u7406\u3082\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>Devise\u306eRegistrationsController\u3092\u7d99\u627f\u3059\u308b\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240\u306f app\/registrations_controller.rb\u3000\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>[ruby mark=&#8221;15-16,29-31&#8243;]<br \/>\nclass RegistrationsController < Devise::RegistrationsController\n\n\n  # POST \/resource\n  def create\n    build_resource(sign_up_params)\n\n    if resource.save\n      yield resource if block_given?\n      if resource.active_for_authentication?\n        set_flash_message :notice, :signed_up if is_flashing_format?\n        sign_up(resource_name, resource)\n        respond_with resource, :location => after_sign_up_path_for(resource)<\/p>\n<p>        #\u72ec\u81ea\u306e\u51e6\u7406\u3092\u8ffd\u52a0<br \/>\n        createXXXX(resource)<\/p>\n<p>      else<br \/>\n        set_flash_message :notice, :&#8221;signed_up_but_#{resource.inactive_message}&#8221; if is_flashing_format?<br \/>\n        expire_data_after_sign_in!<br \/>\n        respond_with resource, :location => after_inactive_sign_up_path_for(resource)<br \/>\n      end<br \/>\n    else<br \/>\n      clean_up_passwords resource<br \/>\n      respond_with resource<br \/>\n    end<br \/>\n  end<\/p>\n<p>  def createXXXX(resource)<br \/>\n     \u3053\u3053\u306b\u8ffd\u52a0\u306e\u51e6\u7406\u3092\u8a18\u8ff0<br \/>\n  end<\/p>\n<p>end<\/p>\n<p>[\/ruby]<\/p>\n<p>routes.rb\u3092\u8abf\u6574\u3057\u3001\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u306b\u3001\u4e0a\u8a18\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<p>[diff]<br \/>\n&#8211; devise_for :users<br \/>\n+ devise_for :users, controllers: {registrations: &#8220;registrations&#8221;}<\/p>\n<p>[\/diff]<\/p>\n<p>\u4ee5\u4e0a\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rails\u306e\u8a8d\u8a3c\u51e6\u7406\u306bdevise\u3092\u7528\u3044\u3066\u3044\u308b\u5834\u5408\u3001\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u306e\u767b\u9332\u306f\u81ea\u52d5\u7684\u306b\u884c\u308f\u308c\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306fUsers\u30c6\u30fc\u30d6\u30eb\u306b\u8a2d\u5b9a\u3057\u305femail\u3068password\u304c\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u3053\u308c\u3067OK\u306a\u306e\u3067\u3059\u304c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4ed5\u69d8\u4e0a\u3001\u30e6\u30fc\u30b6\u30fc\u3092\u65b0\u898f\u306b\u8ffd\u52a0\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u5225\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3057\u305f\u3044\u30b1\u30fc\u30b9\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u305d\u3093\u306a\u30b1\u30fc\u30b9\u306b\u5bfe\u5fdc\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002 devise\u306e\u30bd\u30fc\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3068 RegistrationsController\u306e create\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u767b\u9332\u51e6\u7406\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002\u3067\u3059\u306e\u3067\u3001\u4eca\u56de\u306f\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3066\u3001\u8ffd\u52a0\u306e\u51e6\u7406\u3082\u5b9f\u884c\u3057\u307e\u3059\u3002 Devise\u306eRegistrationsController\u3092\u7d99\u627f\u3059\u308b\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3059\u308b\u3002 \u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240\u306f app\/registrations_controller.rb\u3000\u3068\u3057\u307e\u3059\u3002 [ruby mark=&#8221;15-16,29-31&#8243;] class RegistrationsController < Devise::RegistrationsController # POST \/resource def create build_resource(sign_up_params) if resource.save yield resource if block_given? if resource.active_for_authentication? set_flash_message :notice, :signed_up if is_flashing_format? sign_up(resource_name, resource) respond_with resource, :location => after_sign_up_path_for(resource) #\u72ec\u81ea\u306e\u51e6\u7406\u3092\u8ffd\u52a0 createXXXX(resource) else set_flash_message :notice, :&#8221;signed_up_but_#{resource.inactive_message}&#8221; if is_flashing_format? expire_data_after_sign_in! respond_with resource, :location => after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource respond_with resource end end def createXXXX(resource) \u3053\u3053\u306b\u8ffd\u52a0\u306e\u51e6\u7406\u3092\u8a18\u8ff0 end end [\/ruby] routes.rb\u3092\u8abf\u6574\u3057\u3001\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u306b\u3001\u4e0a\u8a18\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u3002 [diff] &#8211; devise_for :users + devise_for :users, controllers: {registrations: &#8220;registrations&#8221;} [\/diff] \u4ee5\u4e0a\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":407,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[6],"tags":[24,71],"class_list":{"0":"post-201","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-rails","8":"tag-devise","9":"tag-rails"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":5,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"predecessor-version":[{"id":601,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions\/601"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/407"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}