开发者

rails 3 devise before filter

I use devise for authentication, all it's fine but I want to put the before filter to edit user action which is built in devise and have a problem with it cause it's no controller开发者_如何学Go for it. Anybody knows how to do it?


You can alter the controller that is used by Devise by specifying it in your config/routes.rb file:

devise_for :users, :controllers => { :users => "users" } 

Then you would create a UsersController in your application that inherits from the Devise::UsersController and define a before_filter at the beginning of this controller:

class UsersController < Devise::UsersController
  before_filter :some_filter

  private
    def some_filter
      # some code
    end
end

You don't need to define the actions in this controller unless you want to completely override them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜