devise_invitable 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise_invitable might be problematic. Click here for more details.
- data/README.rdoc +25 -1
- data/lib/devise_invitable/inviter.rb +5 -1
- data/lib/devise_invitable/version.rb +1 -1
- metadata +13 -6
data/README.rdoc
CHANGED
@@ -97,6 +97,28 @@ You can also use the generator to generate scoped views:
|
|
97
97
|
|
98
98
|
Please refer to {Devise's README}[http://github.com/plataformatec/devise] for more information about views.
|
99
99
|
|
100
|
+
== Configuring controllers
|
101
|
+
|
102
|
+
To change the controller's behavior, create a controller that inherits from <tt>Devise::InvitationsController</tt>. The available methods are: new, create, edit, and update. You should read the {original controllers source}[https://raw.github.com/scambra/devise_invitable/master/app/controllers/devise/invitations_controller.rb] before editing any of these actions. Your controller might now look something like this:
|
103
|
+
|
104
|
+
class Users::InvitationsController < Devise::InvitationsController
|
105
|
+
def update
|
106
|
+
if this
|
107
|
+
redirect_to root_path
|
108
|
+
else
|
109
|
+
super
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
Now just tell Devise that you want to use your controller, the controller above is 'users/invitations', so our routes.rb would have this line:
|
115
|
+
|
116
|
+
devise_for :users, :controllers => { :invitations => 'users/invitations' }
|
117
|
+
|
118
|
+
be sure that you generate the views and put them into the controller that you generated, so for this example it would be:
|
119
|
+
|
120
|
+
rails generate devise_invitable:views users/invitations
|
121
|
+
|
100
122
|
== Usage
|
101
123
|
|
102
124
|
=== Send an invitation
|
@@ -129,7 +151,9 @@ To accept an invitation with a token use the <tt>accept_invitation!</tt> class m
|
|
129
151
|
Since the invitations controller take care of all the creation/acceptation of an invitation, in most cases you wouldn't call the <tt>invite!</tt> and <tt>accept_invitation!</tt> methods directly.
|
130
152
|
Instead, in your views, put a link to <tt>new_user_invitation_path</tt> or <tt>new_invitation_path(:user)</tt> or even <tt>/users/invitation/new</tt> to prepare and send an invitation (to a user in this example).
|
131
153
|
|
132
|
-
After an invitation is created and sent, the inviter will be redirected to
|
154
|
+
After an invitation is created and sent, the inviter will be redirected to after_sign_in_path_for(resource_name).
|
155
|
+
|
156
|
+
After an invitation is accepted, the invitee will be redirected to after_accept_path_for(resource), which is the same path as after_sign_in_path_for by default. If you want to override the path, override invitations controller and define after_accept_path_for method. This is useful in the common case that a user is invited to a specific location in your application. More on {Devise's README}[http://github.com/plataformatec/devise], "Controller filters and helpers" section.
|
133
157
|
|
134
158
|
The invitation email includes a link to accept the invitation that looks like this: <tt>/users/invitation/accept?invitation_token=abcd123</tt>. When clicked, the invited must set a password in order to accept its invitation. Note that if the invitation_token is not present or not valid, the invited is redirected to after_sign_out_path_for(resource_name).
|
135
159
|
|
@@ -4,7 +4,11 @@ module DeviseInvitable
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
extend ClassMethods
|
7
|
-
|
7
|
+
attr_writer :invitation_limit unless respond_to? :invitation_limit
|
8
|
+
end
|
9
|
+
|
10
|
+
def invitation_limit
|
11
|
+
self[:invitation_limit] || self.class.invitation_limit
|
8
12
|
end
|
9
13
|
|
10
14
|
# Return true if this user has invitations left to send
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_invitable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Cambra
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-24 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
- 0
|
49
49
|
- 0
|
50
50
|
version: 3.0.0
|
51
|
-
- -
|
51
|
+
- - <
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
hash: 3
|
54
54
|
segments:
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
requirement: &id003 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
hash: 25
|
69
69
|
segments:
|
@@ -71,6 +71,13 @@ dependencies:
|
|
71
71
|
- 3
|
72
72
|
- 1
|
73
73
|
version: 1.3.1
|
74
|
+
- - <
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 5
|
77
|
+
segments:
|
78
|
+
- 1
|
79
|
+
- 5
|
80
|
+
version: "1.5"
|
74
81
|
type: :runtime
|
75
82
|
version_requirements: *id003
|
76
83
|
description: It adds support for send invitations by email (it requires to be authenticated) and accept the invitation by setting a password.
|