나는 어쩌면 당신이 (보석 폴더에있는 파일을 덮어 쓸 수 있도록) 레일즈 응용 프로그램 폴더에 루비 파일을 생성하여 방법을 덮어 줄 생각
1. 원래 authenticate_user을! 우리는 우리 자신을 정의 할 수
# GEM_HOME/gems/cancan-2.0.x/lib/devise/controllers/helpers.rb
1 module Devise
2 module Controllers
3 # Those helpers are convenience methods added to ApplicationController.
4 module Helpers
... #.... some code and comments
42 def self.define_helpers(mapping) #:nodoc:
43 mapping = mapping.name
44
45 class_eval <<-METHODS, __FILE__, __LINE__ + 1
46 def authenticate_#{mapping}!(opts={})
47 opts[:scope] = :#{mapping}
48 warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
49 end
2.so : : 방법에 정의되어
# RAILS_APP/lib/devise/controllers/helpers.rb
1 module Devise
2 module Controllers
3 # Those helpers are convenience methods added to ApplicationController.
4 module Helpers
5 def authenticate_user!(opts={})
6 authenticate_if_the_user_is_admin # PUT your hook here.
7 opts[:scope] = :#{mapping}
8 warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
9 # other code...
10 end
11 end
12 end
13end
테스트하지. :-)