lib/devise/rails/routes.rb in devise-1.2.1 vs lib/devise/rails/routes.rb in devise-1.3.0
- old
+ new
@@ -97,10 +97,15 @@
#
# * :skip => tell which controller you want to skip routes from being created:
#
# devise_for :users, :skip => :sessions
#
+ # * :only => the opposite of :skip, tell which controllers only to generate routes to:
+ #
+ # devise_for :users, :only => :sessions
+ #
+ #
# ==== Scoping
#
# Following Rails 3 routes DSL, you can nest devise_for calls inside a scope:
#
# scope "/my" do
@@ -171,9 +176,12 @@
raise unless e.message.include?("undefined method `devise'")
raise_no_devise_method_error!(mapping.class_name)
end
routes = mapping.routes
+ if options.has_key?(:only)
+ routes = Array(options.delete(:only)).map { |s| s.to_s.singularize.to_sym } & mapping.routes
+ end
routes -= Array(options.delete(:skip)).map { |s| s.to_s.singularize.to_sym }
devise_scope mapping.name do
yield if block_given?
with_devise_exclusive_scope mapping.fullpath, mapping.name do