devise-guests 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +37 -0
- data/lib/devise-guests/controllers/helpers.rb +1 -0
- data/lib/devise-guests/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Devise Guests
|
2
|
+
|
3
|
+
A drop-in guest user implementation for devise
|
4
|
+
|
5
|
+
(I'm using "user" to mean my devise model, but you should be able to use any model you want, just like devise)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# install devise first
|
11
|
+
# gem install devise
|
12
|
+
# rails g devise:install
|
13
|
+
# rails g devise User
|
14
|
+
|
15
|
+
gem install devise-guests
|
16
|
+
rails g devise_guests User
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
# Where you might use current_user; now you can use
|
23
|
+
|
24
|
+
current_or_guest_user
|
25
|
+
|
26
|
+
# which returns
|
27
|
+
|
28
|
+
current_user # (for logged in users)
|
29
|
+
|
30
|
+
=> User<id: 1, email: ...>
|
31
|
+
# or
|
32
|
+
|
33
|
+
guest_user # ( for anonymous users)
|
34
|
+
|
35
|
+
=> User<id: nil, email: guest_RANDOMENOUGHSTRING_@example.com, guest: true>
|
36
|
+
|
37
|
+
```
|
@@ -62,6 +62,7 @@ module DeviseGuests::Controllers
|
|
62
62
|
|
63
63
|
private
|
64
64
|
def create_guest_#{mapping} email = nil
|
65
|
+
email &&= nil unless email.to_s.match(/^guest/)
|
65
66
|
email ||= "guest_" + guest_#{mapping}_unique_suffix + "@example.com"
|
66
67
|
u = #{class_name}.create(:email => email)
|
67
68
|
u.password = u.password_confirmation = email
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-guests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise
|
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
segments:
|
174
174
|
- 0
|
175
|
-
hash:
|
175
|
+
hash: 3640487035443286190
|
176
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
177
|
none: false
|
178
178
|
requirements:
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
segments:
|
183
183
|
- 0
|
184
|
-
hash:
|
184
|
+
hash: 3640487035443286190
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
187
|
rubygems_version: 1.8.23
|