Be more friendly if the user goes ahead and adds devise_for :users before defining the model.

This commit is contained in:
José Valim
2010-06-24 16:51:30 +02:00
parent ad63e25c89
commit 7a45043bc8
2 changed files with 7 additions and 2 deletions

View File

@@ -93,6 +93,11 @@ module ActionDispatch::Routing
begin
raise_no_devise_method_error!(mapping.class_name) unless mapping.to.respond_to?(:devise)
rescue NameError => e
raise unless mapping.class_name == resource.to_s.classify
warn "[WARNING] You provided devise_for #{resource.inspect} but there is " <<
"no model #{mapping.class_name} defined in your application"
next
rescue NoMethodError => e
raise unless e.message.include?("undefined method `devise'")
raise_no_devise_method_error!(mapping.class_name)