开发者

I want to customise devise gem's controllers, is it possible and how to do?

Is there a way to customise the devise controllers , as we can modify the devise views using the "rails g devise:views" generator command. ??

Ok purpose here is to create a statistics table's row for the current user as soon as a user is registered.

I have a u开发者_如何学Goser statistics maintained for every user.I just want to trigger the create method of the userstats controller in the background when a user sign-up for my web app.

Is there a way to do this ?


You need to create your own controllers inheriting from Devise's.

class Admins::SessionsController < Devise::SessionsController
end

Then you tell devise to use that controller:

devise_for :admins, :controllers => { :sessions => "admins/sessions" }

And copy your views from devise/sessions, to admin/sessions.

You can read it here: https://github.com/plataformatec/devise


Or simply do this:

rails generate devise:controllers Admin


or copy the devise controllers from where they are now to your app. This is what I did with RVM:

cp -R ~/.rvm/gems/ruby-1.9.3-p194@my_gemset/gems/devise-2.1.0/app/controllers/* my_rails_app/app/controllers/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜