devise 1.1.rc0 → 1.1.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

Files changed (64) hide show
  1. data/CHANGELOG.rdoc +11 -4
  2. data/Gemfile +1 -1
  3. data/README.rdoc +27 -22
  4. data/TODO +0 -1
  5. data/app/helpers/devise_helper.rb +17 -0
  6. data/app/{models → mailers}/devise/mailer.rb +8 -1
  7. data/app/views/devise/confirmations/new.html.erb +2 -2
  8. data/app/views/devise/passwords/edit.html.erb +2 -2
  9. data/app/views/devise/passwords/new.html.erb +2 -2
  10. data/app/views/devise/registrations/edit.html.erb +2 -2
  11. data/app/views/devise/registrations/new.html.erb +3 -2
  12. data/app/views/devise/sessions/new.html.erb +1 -1
  13. data/app/views/devise/shared/_links.erb +1 -1
  14. data/app/views/devise/unlocks/new.html.erb +2 -2
  15. data/config/locales/en.yml +1 -1
  16. data/lib/devise/controllers/internal_helpers.rb +1 -0
  17. data/lib/devise/controllers/scoped_views.rb +1 -1
  18. data/lib/devise/hooks/activatable.rb +1 -20
  19. data/lib/devise/hooks/forgetable.rb +10 -0
  20. data/lib/devise/hooks/rememberable.rb +4 -14
  21. data/lib/devise/mapping.rb +21 -9
  22. data/lib/devise/models.rb +21 -9
  23. data/lib/devise/models/authenticatable.rb +40 -4
  24. data/lib/devise/models/confirmable.rb +0 -4
  25. data/lib/devise/models/database_authenticatable.rb +6 -5
  26. data/lib/devise/models/lockable.rb +6 -10
  27. data/lib/devise/models/rememberable.rb +1 -0
  28. data/lib/devise/models/token_authenticatable.rb +14 -35
  29. data/lib/devise/modules.rb +0 -1
  30. data/lib/devise/rails.rb +2 -0
  31. data/lib/devise/rails/routes.rb +26 -27
  32. data/lib/devise/strategies/authenticatable.rb +0 -12
  33. data/lib/devise/strategies/base.rb +14 -0
  34. data/lib/devise/strategies/database_authenticatable.rb +1 -0
  35. data/lib/devise/strategies/rememberable.rb +3 -1
  36. data/lib/devise/strategies/token_authenticatable.rb +4 -1
  37. data/lib/devise/version.rb +1 -1
  38. data/lib/generators/devise/devise_generator.rb +1 -1
  39. data/lib/generators/devise/templates/migration.rb +2 -0
  40. data/lib/generators/devise_install/templates/README +6 -0
  41. data/lib/generators/devise_views/devise_views_generator.rb +2 -2
  42. data/test/integration/confirmable_test.rb +2 -2
  43. data/test/integration/database_authenticatable_test.rb +7 -7
  44. data/test/integration/lockable_test.rb +10 -2
  45. data/test/integration/recoverable_test.rb +3 -3
  46. data/test/integration/registerable_test.rb +1 -1
  47. data/test/integration/rememberable_test.rb +1 -1
  48. data/test/mapping_test.rb +11 -9
  49. data/test/models/lockable_test.rb +3 -0
  50. data/test/models/token_authenticatable_test.rb +4 -11
  51. data/test/models_test.rb +9 -2
  52. data/test/rails_app/app/active_record/admin.rb +1 -1
  53. data/test/rails_app/app/active_record/user.rb +1 -1
  54. data/test/rails_app/app/data_mapper/admin.rb +1 -2
  55. data/test/rails_app/app/data_mapper/user.rb +1 -1
  56. data/test/rails_app/app/mongoid/admin.rb +1 -1
  57. data/test/rails_app/app/mongoid/user.rb +1 -1
  58. data/test/rails_app/config/application.rb +0 -4
  59. data/test/rails_app/config/environments/test.rb +2 -0
  60. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  61. data/test/rails_app/config/routes.rb +2 -2
  62. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +1 -1
  63. metadata +7 -5
  64. data/lib/devise/models/activatable.rb +0 -16
data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- == 1.1.pre
1
+ == 1.1.rc1
2
2
 
3
3
  * enhancements
4
4
  * Rails 3 compatibility.
@@ -17,11 +17,10 @@
17
17
  * TokenAuthenticatable now works with HTTP Basic Auth.
18
18
  * Allow :unlock_strategy to be :none and add :lock_strategy which can be :failed_attempts or none. Setting those values to :none means that you want to handle lock and unlocking by yourself.
19
19
  * No need to append ?unauthenticated=true in URLs anymore since Flash was moved to a middleware in Rails 3.
20
- * All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure.
20
+ * :activatable is included by default in your models.
21
21
 
22
22
  * bug fix
23
- * Do not allow unlockable strategies based on time to access a controller.
24
- * Do not send unlockable email several times.
23
+ * fix a bug with STI
25
24
 
26
25
  * deprecations
27
26
  * Rails 3 compatible only.
@@ -29,6 +28,14 @@
29
28
  * Devise.orm is deprecated, just require "devise/orm/YOUR_ORM" instead.
30
29
  * Devise.default_url_options is deprecated, just modify ApplicationController.default_url_options.
31
30
  * All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure.
31
+ * :as and :scope in routes is deprecated. Use :path and :singular instead.
32
+
33
+ == 1.0.6
34
+
35
+ * bug fix
36
+ * Do not allow unlockable strategies based on time to access a controller.
37
+ * Do not send unlockable email several times.
38
+ * Allow controller to upstram custom! failures to Warden.
32
39
 
33
40
  == 1.0.5
34
41
 
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://gemcutter.org"
2
2
 
3
3
  # Need to install Rails from source
4
- gem "rails", "3.0.0.beta2"
4
+ gem "rails", "3.0.0.beta3"
5
5
  gem "warden", "0.10.3"
6
6
  gem "sqlite3-ruby", :require => "sqlite3"
7
7
  gem "webrat", "0.7"
data/README.rdoc CHANGED
@@ -19,7 +19,6 @@ Right now it's composed of 11 modules:
19
19
  * Timeoutable: expires sessions that have no activity in a specified period of time.
20
20
  * Validatable: provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
21
21
  * Lockable: locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
22
- * Activatable: use this module if you need to activate accounts by means other than confirmation.
23
22
 
24
23
  == Examples
25
24
 
@@ -32,11 +31,11 @@ Devise is based on Warden (http://github.com/hassox/warden), a Rack Authenticati
32
31
 
33
32
  == Installation
34
33
 
35
- Devise master branch now supports Rails 3 and is NOT backward compatible. If you are using Rails 3.0.0 beta gem, you need to install devise as a gem:
34
+ Devise master branch now supports Rails 3 and is NOT backward compatible. You can use the latest Rails 3 beta gem with Devise latest gem:
36
35
 
37
- sudo gem install devise --version=1.1.pre4
36
+ sudo gem install devise --version=1.1.rc1
38
37
 
39
- However, if you are using Rails edge, from the git repository, you also need to use Devise from the git repository. After you install Devise and add it to your gemfile, you need to run the generator:
38
+ After you install Devise and add it to your Gemfile, you need to run the generator:
40
39
 
41
40
  rails generate devise_install
42
41
 
@@ -44,11 +43,15 @@ And you're ready to go. The generator will install an initializer which describe
44
43
 
45
44
  http://rdoc.info/projects/plataformatec/devise
46
45
 
46
+ The documentation above is for Rails 3. If you want to consult the documentation for Rails 2.3, you need to start `gem server` in your own machine. Finally, another good resource for information, is the wiki:
47
+
48
+ http://wiki.github.com/plataformatec/devise
49
+
47
50
  == Rails 2.3
48
51
 
49
52
  If you want to use the Rails 2.3.x version, you should do:
50
53
 
51
- sudo gem install devise --version=1.0.4
54
+ sudo gem install devise --version=1.0.6
52
55
 
53
56
  Or checkout from the v1.0 branch:
54
57
 
@@ -63,13 +66,13 @@ Devise must be set up within the model (or models) you want to use. Devise route
63
66
  We're assuming here you want a User model with some Devise modules, as outlined below:
64
67
 
65
68
  class User < ActiveRecord::Base
66
- devise :authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
69
+ devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
67
70
  end
68
71
 
69
72
  After you choose which modules to use, you need to set up your migrations. Luckily, Devise has some helpers to save you from this boring work:
70
73
 
71
74
  create_table :users do |t|
72
- t.authenticatable
75
+ t.database_authenticatable
73
76
  t.confirmable
74
77
  t.recoverable
75
78
  t.rememberable
@@ -127,13 +130,13 @@ Devise allows you to set up as many roles as you want. For example, you may have
127
130
 
128
131
  # Create a migration with the required fields
129
132
  create_table :admins do |t|
130
- t.authenticatable
133
+ t.database_authenticatable
131
134
  t.lockable
132
135
  t.trackable
133
136
  end
134
137
 
135
138
  # Inside your Admin model
136
- devise :authenticatable, :trackable, :timeoutable, :lockable
139
+ devise :database_authenticatable, :trackable, :timeoutable, :lockable
137
140
 
138
141
  # Inside your routes
139
142
  devise_for :admin
@@ -162,36 +165,38 @@ This will create a model named "Model" configured with default Devise modules an
162
165
 
163
166
  == Model configuration
164
167
 
165
- The devise method in your models also accepts some options to configure its modules. For example, you can choose which encryptor to use in authenticatable:
168
+ The devise method in your models also accepts some options to configure its modules. For example, you can choose which encryptor to use in database_authenticatable:
166
169
 
167
- devise :authenticatable, :confirmable, :recoverable, :encryptor => :bcrypt
170
+ devise :database_authenticatable, :confirmable, :recoverable, :encryptor => :bcrypt
168
171
 
169
172
  Besides :encryptor, you can define :pepper, :stretches, :confirm_within, :remember_for, :timeout_in, :unlock_in and other values. For details, see the initializer file that was created when you invoked the devise_install generator described above.
170
173
 
171
- == Configuring controllers and views
174
+ == Configuring views
172
175
 
173
- We built Devise to help you quickly develop an application that uses authentication. We don't want to be in your way when you need to customize it.
176
+ We built Devise to help you quickly develop an application that uses authentication. However, we don't want to be in your way when you need to customize it.
174
177
 
175
- Since Devise is an engine, all its default views are packaged inside the gem. The default views will get you started but you may want to customize them. Devise has a generator to copy the default views to your application. After they've been copied to your application, you can make changes as required:
178
+ Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after sometime you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
176
179
 
177
180
  rails generate devise_views
178
181
 
179
- If you have more than one role in your application (such as "user" and "admin"), you will notice that Devise uses the same views for all roles. You may need different views for each role. Devise offers an easy way to customize views for each role. Just set config.scoped_views to "true" inside "config/initializers/devise.rb".
182
+ However, if you have more than one role in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all roles. Fortunately, Devise offers an easy way to customize views. All you need to do is set "config.scoped_views = true" inside "config/initializers/devise.rb".
183
+
184
+ After doing so, you will be able to have views based on the role like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new".
180
185
 
181
- After doing so you will be able to have views based on the scope like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new".
186
+ == Configuring controllers
182
187
 
183
- Finally, if the customization at the views level is not enough, you can customize each controller by following these steps:
188
+ If the customization at the views level is not enough, you can customize each controller by following these steps:
184
189
 
185
- 1) Create your custom controller, for example a Admins::SessionsController:
190
+ 1) Create your custom controller, for example a Admins::SessionsController:
186
191
 
187
192
  class Admins::SessionsController < Devise::SessionsController
188
193
  end
189
194
 
190
- 2) Tell the router to use this controller:
195
+ 2) Tell the router to use this controller:
191
196
 
192
- devise_for :admins, :controllers => { :sessions = "admin/sessions" }
197
+ devise_for :admins, :controllers => { :sessions => "admin/sessions" }
193
198
 
194
- 3) And finally, since we changed the controller, it won't use the "devise/sessions" views, so remember to copy "devise/sessions" to "admin/sessions".
199
+ 3) And since we changed the controller, it won't use the "devise/sessions" views, so remember to copy "devise/sessions" to "admin/sessions".
195
200
 
196
201
  Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call "flash[:notice]" and "flash[:alert]" as appropriate.
197
202
 
@@ -285,7 +290,7 @@ http://groups.google.com/group/plataformatec-devise
285
290
 
286
291
  See the wiki for additional documentation and support.
287
292
 
288
- http://wiki.github.com/plataformatec/devise/
293
+ http://wiki.github.com/plataformatec/devise
289
294
 
290
295
  == License
291
296
 
data/TODO CHANGED
@@ -1,3 +1,2 @@
1
- * Extract Activatable tests from Confirmable
2
1
  * Move integration tests to Capybara
3
2
  * Better ORM integration
@@ -0,0 +1,17 @@
1
+ module DeviseHelper
2
+ def devise_error_messages!
3
+ return "" if resource.errors.empty?
4
+
5
+ messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
6
+ sentence = "#{pluralize(resource.errors.count, "error")} prohibited this #{resource_name} from being saved:"
7
+
8
+ html = <<-HTML
9
+ <div id="error_explanation">
10
+ <h2>#{sentence}</h2>
11
+ <ul>#{messages}</ul>
12
+ </div>
13
+ HTML
14
+
15
+ html.html_safe
16
+ end
17
+ end
@@ -24,7 +24,7 @@ class Devise::Mailer < ::ActionMailer::Base
24
24
  @resource = instance_variable_set("@#{@devise_mapping.name}", record)
25
25
 
26
26
  template_path = ["devise/mailer"]
27
- template_path.unshift "#{@devise_mapping.as}/mailer" if self.class.scoped_views?
27
+ template_path.unshift "#{@devise_mapping.plural}/mailer" if self.class.scoped_views?
28
28
 
29
29
  headers = {
30
30
  :subject => translate(@devise_mapping, action),
@@ -37,6 +37,13 @@ class Devise::Mailer < ::ActionMailer::Base
37
37
  mail(headers)
38
38
  end
39
39
 
40
+ # Fix a bug in Rails 3 beta 3
41
+ def mail(*) #:nodoc:
42
+ super
43
+ @_message["template_path"] = nil
44
+ @_message
45
+ end
46
+
40
47
  def mailer_sender(mapping)
41
48
  if Devise.mailer_sender.is_a?(Proc)
42
49
  Devise.mailer_sender.call(mapping.name)
@@ -1,7 +1,7 @@
1
1
  <h2>Resend confirmation instructions</h2>
2
2
 
3
- <%= form_for(resource_name, resource, :url => confirmation_path(resource_name)) do |f| %>
4
- <%= f.error_messages %>
3
+ <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name)) do |f| %>
4
+ <%= devise_error_messages! %>
5
5
 
6
6
  <p><%= f.label :email %></p>
7
7
  <p><%= f.text_field :email %></p>
@@ -1,7 +1,7 @@
1
1
  <h2>Change your password</h2>
2
2
 
3
- <%= form_for(resource_name, resource, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
4
- <%= f.error_messages %>
3
+ <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
5
  <%= f.hidden_field :reset_password_token %>
6
6
 
7
7
  <p><%= f.label :password %></p>
@@ -1,7 +1,7 @@
1
1
  <h2>Forgot your password?</h2>
2
2
 
3
- <%= form_for(resource_name, resource, :url => password_path(resource_name)) do |f| %>
4
- <%= f.error_messages %>
3
+ <%= form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f| %>
4
+ <%= devise_error_messages! %>
5
5
 
6
6
  <p><%= f.label :email %></p>
7
7
  <p><%= f.text_field :email %></p>
@@ -1,7 +1,7 @@
1
1
  <h2>Edit <%= resource_name.to_s.humanize %></h2>
2
2
 
3
- <%= form_for(resource_name, resource, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4
- <%= f.error_messages %>
3
+ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
5
 
6
6
  <p><%= f.label :email %></p>
7
7
  <p><%= f.text_field :email %></p>
@@ -1,7 +1,8 @@
1
1
  <h2>Sign up</h2>
2
2
 
3
- <%= form_for(resource_name, resource, :url => registration_path(resource_name)) do |f| %>
4
- <%= f.error_messages %>
3
+ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
5
6
  <p><%= f.label :email %></p>
6
7
  <p><%= f.text_field :email %></p>
7
8
 
@@ -1,6 +1,6 @@
1
1
  <h2>Sign in</h2>
2
2
 
3
- <%= form_for(resource_name, resource, :url => session_path(resource_name)) do |f| %>
3
+ <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4
4
  <p><%= f.label :email %></p>
5
5
  <p><%= f.text_field :email %></p>
6
6
 
@@ -14,6 +14,6 @@
14
14
  <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
15
15
  <% end -%>
16
16
 
17
- <%- if devise_mapping.lockable? && controller_name != 'unlocks' %>
17
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
18
  <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
19
19
  <% end -%>
@@ -1,7 +1,7 @@
1
1
  <h2>Resend unlock instructions</h2>
2
2
 
3
- <%= form_for(resource_name, resource, :url => unlock_path(resource_name)) do |f| %>
4
- <%= f.error_messages %>
3
+ <%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name)) do |f| %>
4
+ <%= devise_error_messages! %>
5
5
 
6
6
  <p><%= f.label :email %></p>
7
7
  <p><%= f.text_field :email %></p>
@@ -24,7 +24,7 @@ en:
24
24
  send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
25
25
  confirmed: 'Your account was successfully confirmed. You are now signed in.'
26
26
  registrations:
27
- signed_up: 'You have signed up successfully.'
27
+ signed_up: 'You have signed up successfully. If enabled, a confirmation was sent your e-mail.'
28
28
  updated: 'You updated your account successfully.'
29
29
  destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
30
30
  unlocks:
@@ -9,6 +9,7 @@ module Devise
9
9
 
10
10
  included do
11
11
  unloadable
12
+ helper DeviseHelper
12
13
 
13
14
  helpers = %w(resource scope_name resource_name
14
15
  resource_class devise_mapping devise_controller?)
@@ -22,7 +22,7 @@ module Devise
22
22
 
23
23
  if self.class.scoped_views?
24
24
  begin
25
- render :template => "#{devise_mapping.as}/#{controller_name}/#{action}"
25
+ render :template => "#{devise_mapping.plural}/#{controller_name}/#{action}"
26
26
  rescue ActionView::MissingTemplate
27
27
  render :template => "#{controller_path}/#{action}"
28
28
  end
@@ -5,23 +5,4 @@ Warden::Manager.after_set_user do |record, warden, options|
5
5
  warden.logout(scope)
6
6
  throw :warden, :scope => scope, :message => record.inactive_message
7
7
  end
8
- end
9
-
10
- module Devise
11
- module Hooks
12
- # Overwrite Devise base strategy to only authenticate an user if it's active.
13
- # If you have an strategy that does not use Devise::Strategy::Base, don't worry
14
- # because the hook above will still avoid it to authenticate.
15
- module Activatable
16
- def success!(resource)
17
- if resource.respond_to?(:active?) && !resource.active?
18
- fail!(resource.inactive_message)
19
- else
20
- super
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
27
- Devise::Strategies::Base.send :include, Devise::Hooks::Activatable
8
+ end
@@ -0,0 +1,10 @@
1
+ # Before logout hook to forget the user in the given scope, if it responds
2
+ # to forget_me! Also clear remember token to ensure the user won't be
3
+ # remembered again. Notice that we forget the user unless the record is frozen.
4
+ # This avoids forgetting deleted users.
5
+ Warden::Manager.before_logout do |record, warden, scope|
6
+ if record.respond_to?(:forget_me!)
7
+ record.forget_me! unless record.frozen?
8
+ warden.cookies.delete "remember_#{scope}_token"
9
+ end
10
+ end
@@ -1,19 +1,9 @@
1
- # Before logout hook to forget the user in the given scope, if it responds
2
- # to forget_me! Also clear remember token to ensure the user won't be
3
- # remembered again. Notice that we forget the user unless the record is frozen.
4
- # This avoids forgetting deleted users.
5
- Warden::Manager.before_logout do |record, warden, scope|
6
- if record.respond_to?(:forget_me!)
7
- record.forget_me! unless record.frozen?
8
- warden.cookies.delete "remember_#{scope}_token"
9
- end
10
- end
11
-
12
1
  module Devise
13
2
  module Hooks
14
3
  # Overwrite success! in authentication strategies allowing users to be remembered.
15
- # We choose to implement this as an strategy hook instead of a Devise hook to avoid users
16
- # giving a remember_me access in strategies that should not create remember me tokens.
4
+ # We choose to implement this as an strategy hook instead of a warden hook to allow a specific
5
+ # strategy (like token authenticatable or facebook authenticatable) to turn off remember_me?
6
+ # cookies.
17
7
  module Rememberable #:nodoc:
18
8
  def success!(resource)
19
9
  super
@@ -29,7 +19,7 @@ module Devise
29
19
  end
30
20
  end
31
21
 
32
- protected
22
+ protected
33
23
 
34
24
  def remember_me?
35
25
  valid_params? && Devise::TRUE_VALUES.include?(params_auth_hash[:remember_me])
@@ -22,14 +22,15 @@ module Devise
22
22
  # # is the modules included in the class
23
23
  #
24
24
  class Mapping #:nodoc:
25
- attr_reader :name, :as, :controllers, :path_names, :path_prefix
25
+ attr_reader :singular, :plural, :path, :controllers, :path_names, :path_prefix
26
+ alias :name :singular
26
27
 
27
28
  # Loop through all mappings looking for a map that matches with the requested
28
29
  # path (ie /users/sign_in). If a path prefix is given, it's taken into account.
29
30
  def self.find_by_path(path)
30
31
  Devise.mappings.each_value do |mapping|
31
- route = path.split("/")[mapping.as_position]
32
- return mapping if route && mapping.as == route.to_sym
32
+ route = path.split("/")[mapping.segment_position]
33
+ return mapping if route && mapping.path == route.to_sym
33
34
  end
34
35
  nil
35
36
  end
@@ -50,9 +51,20 @@ module Devise
50
51
  end
51
52
 
52
53
  def initialize(name, options) #:nodoc:
53
- @as = (options.delete(:as) || name).to_sym
54
- @klass = (options.delete(:class_name) || name.to_s.classify).to_s
55
- @name = (options.delete(:scope) || name.to_s.singularize).to_sym
54
+ if as = options.delete(:as)
55
+ ActiveSupport::Deprecation.warn ":as is deprecated, please use :path instead."
56
+ options[:path] ||= as
57
+ end
58
+
59
+ if scope = options.delete(:scope)
60
+ ActiveSupport::Deprecation.warn ":scope is deprecated, please use :singular instead."
61
+ options[:singular] ||= scope
62
+ end
63
+
64
+ @plural = name.to_sym
65
+ @path = (options.delete(:path) || name).to_sym
66
+ @klass = (options.delete(:class_name) || name.to_s.classify).to_s
67
+ @singular = (options.delete(:singular) || name.to_s.singularize).to_sym
56
68
 
57
69
  @path_prefix = "/#{options.delete(:path_prefix)}/".squeeze("/")
58
70
 
@@ -96,13 +108,13 @@ module Devise
96
108
  end
97
109
 
98
110
  # Return in which position in the path prefix devise should find the as mapping.
99
- def as_position
111
+ def segment_position
100
112
  self.path_prefix.count("/")
101
113
  end
102
114
 
103
115
  # Returns the raw path using path_prefix and as.
104
- def path
105
- path_prefix + as.to_s
116
+ def full_path
117
+ path_prefix + path.to_s
106
118
  end
107
119
 
108
120
  def authenticatable?