acts_as_user 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +91 -11
- data/lib/acts_as_user/version.rb +1 -1
- data/lib/generators/active_record/templates/existing_migration.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a7e5bcbb549bcaee0d7e66f93759c2bc3061b5d
|
4
|
+
data.tar.gz: f4f9c9205329ceb26c70427beecf1d8a72fb1215
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b88ebfdb46ed4f836bb96ad0df2714f76fe286ea2d6e80b73fb4af015b7004c5e6a19134a409a716096eb9e3ff740fef64b0c28bb38404c7c0fdccb74c71c29
|
7
|
+
data.tar.gz: 298b5b4a6c8b97cb073bbf38de14d4177f83524340559849b086daaff45a7935d47b8bbf6abb1216c8709d05135cee0f37aa38bf596f39228dbc650679043b03
|
data/README.md
CHANGED
@@ -1,24 +1,74 @@
|
|
1
|
-
#
|
1
|
+
#Acts as user
|
2
2
|
|
3
|
-
|
3
|
+
Acts as user handles multiple user roles on a rails app. It uses polymorphic associations to relate other models and behave like a user.
|
4
4
|
|
5
|
-
## Installation
|
6
5
|
|
7
|
-
|
6
|
+
## Getting started
|
8
7
|
|
9
|
-
|
8
|
+
ActsAsUser 1.0.0 works with rails 3 onwards. You can add it to your Gemfile with:
|
10
9
|
|
11
|
-
|
10
|
+
```ruby
|
11
|
+
gem 'acts_as_user'
|
12
|
+
```
|
12
13
|
|
13
|
-
|
14
|
+
Then run the bundle command to install it.
|
14
15
|
|
15
|
-
|
16
|
+
After you install ActsAsUser you need to run the generator:
|
16
17
|
|
17
|
-
|
18
|
+
```console
|
19
|
+
rails g acts_as_user:install
|
20
|
+
```
|
18
21
|
|
19
|
-
|
22
|
+
The generator will install in initializer which describes all the ActsAsUser configuration options, so we recommend you take a look at it. When you are done you are ready to start your user model:
|
20
23
|
|
21
|
-
|
24
|
+
```console
|
25
|
+
rails g acts_as_user User <attributes>
|
26
|
+
```
|
27
|
+
|
28
|
+
Next you'll probably want to run the migrations "rake db:migrate", as the generator will create a migration file (open it modify if you need to).
|
29
|
+
|
30
|
+
##Configuration
|
31
|
+
|
32
|
+
For the models you want to inherit to you just have to add this line of code into them:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
class Member
|
36
|
+
acts_as_user
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
A little note on the User model...just in case!
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
class User
|
44
|
+
is_user
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
###Ignore attributes to delegate from the user
|
49
|
+
|
50
|
+
If you want to ignore some attributes from your user model to the childs, you can do it on the ```acts_as_user.rb``` initializer like so:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
ActsAsUser.setup do |config|
|
54
|
+
config.ignored_attributes = ["name", "bio"]
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
By default it ignores the following attributes:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
["created_at", "updated_at", "id", "userable_type", "userable_id"]
|
62
|
+
```
|
63
|
+
|
64
|
+
|
65
|
+
##Devise support
|
66
|
+
|
67
|
+
Yes we do!
|
68
|
+
|
69
|
+
Acts as a user plays well with Devise as it ignores and adds the corresponding attributes to delegate to.
|
70
|
+
|
71
|
+
When using devise, ActsAsUser will also ignore the ```encrypted_password``` attribute from the user. No further configuration needs to be done.
|
22
72
|
|
23
73
|
## Contributing
|
24
74
|
|
@@ -27,3 +77,33 @@ TODO: Write usage instructions here
|
|
27
77
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
78
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
79
|
5. Create new Pull Request
|
80
|
+
|
81
|
+
|
82
|
+
###Psst! Here is a live example in rails
|
83
|
+
|
84
|
+
[Rails acts as user example](https://github.com/IcaliaLabs)
|
85
|
+
|
86
|
+
### Devs
|
87
|
+
|
88
|
+
* Abraham Kuri (https://github.com/kurenn)
|
89
|
+
* Patricio Beltrán (https://github.com/patobeltran)
|
90
|
+
|
91
|
+
### Future
|
92
|
+
|
93
|
+
* Add tests
|
94
|
+
* Support for Mongoid
|
95
|
+
* Add wiki
|
96
|
+
|
97
|
+
|
98
|
+
## Credits
|
99
|
+
Icalia Labs - weare@icalialabs.com
|
100
|
+
|
101
|
+
[Follow us](http://twitter.com/icalialabs "Follow us")
|
102
|
+
|
103
|
+
|
104
|
+
[Like us on Facebook](https://www.facebook.com/icalialab "Like us on Facebook")
|
105
|
+
|
106
|
+
|
107
|
+
### License
|
108
|
+
|
109
|
+
MIT License. Copyright 2012-2013 IcaliaLabs. http://icalialabs.com
|
data/lib/acts_as_user/version.rb
CHANGED