68
62

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rails devise 管理者から他のユーザーを登録する。

Posted at

#rails devise 管理者から他のユーザーを登録

##railsで管理機能
####ログイン機能 devise

すでにログインしている状態から、新しいアカウントの作成画面に遷移すると、
リダイレクトで、ホーム画面に戻ってしまう。

####deviseのregistrationsのコントローラーを作成

$rails g controller users/sessions

####Devise::RegistrationsControllerを継承する

class Users::RegistrationsController < Devise::RegistrationsController
end

継承したRegistratoinsControllerのfilterをオーバーライド

class Users::RegistrationsController < Devise::RegistrationsController
    prepend_before_filter :require_no_authentication, :only => [ :cancel]
    prepend_before_filter :authenticate_scope!, :only => [:new, :create ,:edit, :update, :destroy]
end

ちなみにdefaultは、
/usr/local/lib/ruby/gems/2.0.0/gems/devise-3.2.1/app/controllers/devise

class Devise::RegistrationsController < DeviseController
  prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
  prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]

これでログイン中でもログインユーザーが登録できました。

68
62
1

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
68
62

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?