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.
- data/CHANGELOG.rdoc +11 -4
- data/Gemfile +1 -1
- data/README.rdoc +27 -22
- data/TODO +0 -1
- data/app/helpers/devise_helper.rb +17 -0
- data/app/{models → mailers}/devise/mailer.rb +8 -1
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/passwords/edit.html.erb +2 -2
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +2 -2
- data/app/views/devise/registrations/new.html.erb +3 -2
- data/app/views/devise/sessions/new.html.erb +1 -1
- data/app/views/devise/shared/_links.erb +1 -1
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/config/locales/en.yml +1 -1
- data/lib/devise/controllers/internal_helpers.rb +1 -0
- data/lib/devise/controllers/scoped_views.rb +1 -1
- data/lib/devise/hooks/activatable.rb +1 -20
- data/lib/devise/hooks/forgetable.rb +10 -0
- data/lib/devise/hooks/rememberable.rb +4 -14
- data/lib/devise/mapping.rb +21 -9
- data/lib/devise/models.rb +21 -9
- data/lib/devise/models/authenticatable.rb +40 -4
- data/lib/devise/models/confirmable.rb +0 -4
- data/lib/devise/models/database_authenticatable.rb +6 -5
- data/lib/devise/models/lockable.rb +6 -10
- data/lib/devise/models/rememberable.rb +1 -0
- data/lib/devise/models/token_authenticatable.rb +14 -35
- data/lib/devise/modules.rb +0 -1
- data/lib/devise/rails.rb +2 -0
- data/lib/devise/rails/routes.rb +26 -27
- data/lib/devise/strategies/authenticatable.rb +0 -12
- data/lib/devise/strategies/base.rb +14 -0
- data/lib/devise/strategies/database_authenticatable.rb +1 -0
- data/lib/devise/strategies/rememberable.rb +3 -1
- data/lib/devise/strategies/token_authenticatable.rb +4 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/devise/devise_generator.rb +1 -1
- data/lib/generators/devise/templates/migration.rb +2 -0
- data/lib/generators/devise_install/templates/README +6 -0
- data/lib/generators/devise_views/devise_views_generator.rb +2 -2
- data/test/integration/confirmable_test.rb +2 -2
- data/test/integration/database_authenticatable_test.rb +7 -7
- data/test/integration/lockable_test.rb +10 -2
- data/test/integration/recoverable_test.rb +3 -3
- data/test/integration/registerable_test.rb +1 -1
- data/test/integration/rememberable_test.rb +1 -1
- data/test/mapping_test.rb +11 -9
- data/test/models/lockable_test.rb +3 -0
- data/test/models/token_authenticatable_test.rb +4 -11
- data/test/models_test.rb +9 -2
- data/test/rails_app/app/active_record/admin.rb +1 -1
- data/test/rails_app/app/active_record/user.rb +1 -1
- data/test/rails_app/app/data_mapper/admin.rb +1 -2
- data/test/rails_app/app/data_mapper/user.rb +1 -1
- data/test/rails_app/app/mongoid/admin.rb +1 -1
- data/test/rails_app/app/mongoid/user.rb +1 -1
- data/test/rails_app/config/application.rb +0 -4
- data/test/rails_app/config/environments/test.rb +2 -0
- data/test/rails_app/config/initializers/secret_token.rb +2 -0
- data/test/rails_app/config/routes.rb +2 -2
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +1 -1
- metadata +7 -5
- data/lib/devise/models/activatable.rb +0 -16
data/CHANGELOG.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
== 1.1.
|
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
|
-
*
|
20
|
+
* :activatable is included by default in your models.
|
21
21
|
|
22
22
|
* bug fix
|
23
|
-
*
|
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
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.
|
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.
|
36
|
+
sudo gem install devise --version=1.1.rc1
|
38
37
|
|
39
|
-
|
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.
|
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 :
|
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.
|
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.
|
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 :
|
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
|
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 :
|
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
|
174
|
+
== Configuring views
|
172
175
|
|
173
|
-
We built Devise to help you quickly develop an application that uses authentication.
|
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
|
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
|
-
|
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
|
-
|
186
|
+
== Configuring controllers
|
182
187
|
|
183
|
-
|
188
|
+
If the customization at the views level is not enough, you can customize each controller by following these steps:
|
184
189
|
|
185
|
-
|
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
|
-
|
195
|
+
2) Tell the router to use this controller:
|
191
196
|
|
192
|
-
devise_for :admins, :controllers => { :sessions
|
197
|
+
devise_for :admins, :controllers => { :sessions => "admin/sessions" }
|
193
198
|
|
194
|
-
|
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
@@ -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.
|
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(
|
4
|
-
<%=
|
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(
|
4
|
-
<%=
|
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(
|
4
|
-
<%=
|
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(
|
4
|
-
<%=
|
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(
|
4
|
-
<%=
|
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(
|
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(
|
4
|
-
<%=
|
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>
|
data/config/locales/en.yml
CHANGED
@@ -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:
|
@@ -22,7 +22,7 @@ module Devise
|
|
22
22
|
|
23
23
|
if self.class.scoped_views?
|
24
24
|
begin
|
25
|
-
render :template => "#{devise_mapping.
|
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
|
16
|
-
#
|
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
|
-
|
22
|
+
protected
|
33
23
|
|
34
24
|
def remember_me?
|
35
25
|
valid_params? && Devise::TRUE_VALUES.include?(params_auth_hash[:remember_me])
|
data/lib/devise/mapping.rb
CHANGED
@@ -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 :
|
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.
|
32
|
-
return mapping if route && mapping.
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
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
|
105
|
-
path_prefix +
|
116
|
+
def full_path
|
117
|
+
path_prefix + path.to_s
|
106
118
|
end
|
107
119
|
|
108
120
|
def authenticatable?
|