rails_apps_pages 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.textile +4 -0
- data/lib/generators/pages/authorized/authorized_generator.rb +4 -1
- data/lib/generators/pages/authorized/templates/user_policy.rb +21 -0
- data/lib/generators/pages/users/users_generator.rb +2 -1
- data/lib/rails_apps_pages/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dabd0b8953eea28a91d4e338405ec9246b063f63
|
4
|
+
data.tar.gz: 64fd9902b64d7ef3b45522b63c1fe8d91640f5ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d4cf28f09932dd29353eb59ccc520f1db3c6eeb2601ac90848e4392cc94dd1fbd134f0d9fc18155d99f3d6c3b8872b928ab928d6e9f154bed65892cd896d6c
|
7
|
+
data.tar.gz: 121b0a57c871377b70af93b0b2f8d282470f447decc419ede45051111d83cad1e2792982f6378ae71cf50f55af882c4d9d129b1fcc819dfb363259d62eeccfd3
|
data/CHANGELOG.textile
CHANGED
@@ -8,12 +8,15 @@ module Pages
|
|
8
8
|
desc "Create pages to accompany a User model when authorization is available."
|
9
9
|
|
10
10
|
def create_page
|
11
|
+
### assumes we are using Devise for authentication
|
12
|
+
### assumes we are using Pundit for authorization
|
11
13
|
copy_file 'users/_user.html.erb', 'app/views/users/_user.html.erb'
|
12
14
|
copy_file 'users/index.html.erb', 'app/views/users/index.html.erb'
|
13
15
|
copy_file 'users/show.html.erb', 'app/views/users/show.html.erb'
|
14
16
|
copy_file 'users_controller.rb', 'app/controllers/users_controller.rb'
|
17
|
+
copy_file 'user_policy.rb', 'app/policies/user_policy.rb'
|
15
18
|
route = ' resources :users'
|
16
|
-
inject_into_file 'config/routes.rb', route + "\n", :
|
19
|
+
inject_into_file 'config/routes.rb', route + "\n", :after => "devise_for :users\n"
|
17
20
|
copy_file 'visitors/index.html.erb', 'app/views/visitors/index.html.erb'
|
18
21
|
copy_file 'visitors_controller.rb', 'app/controllers/visitors_controller.rb'
|
19
22
|
route = ' root :to => "visitors#index"'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class UserPolicy
|
2
|
+
attr_reader :user, :record
|
3
|
+
|
4
|
+
def initialize(user, record)
|
5
|
+
@user = user
|
6
|
+
@record = record
|
7
|
+
end
|
8
|
+
|
9
|
+
def index?
|
10
|
+
@user.admin?
|
11
|
+
end
|
12
|
+
|
13
|
+
def update?
|
14
|
+
@user.admin?
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy?
|
18
|
+
@user.admin?
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -8,12 +8,13 @@ module Pages
|
|
8
8
|
desc "Create pages to accompany a User model when authentication is available."
|
9
9
|
|
10
10
|
def create_page
|
11
|
+
### assumes we are using Devise for authentication
|
11
12
|
copy_file 'users/_user.html.erb', 'app/views/users/_user.html.erb'
|
12
13
|
copy_file 'users/index.html.erb', 'app/views/users/index.html.erb'
|
13
14
|
copy_file 'users/show.html.erb', 'app/views/users/show.html.erb'
|
14
15
|
copy_file 'users_controller.rb', 'app/controllers/users_controller.rb'
|
15
16
|
route = ' resources :users'
|
16
|
-
inject_into_file 'config/routes.rb', route + "\n", :
|
17
|
+
inject_into_file 'config/routes.rb', route + "\n", :after => "devise_for :users\n"
|
17
18
|
copy_file 'visitors/index.html.erb', 'app/views/visitors/index.html.erb'
|
18
19
|
copy_file 'visitors_controller.rb', 'app/controllers/visitors_controller.rb'
|
19
20
|
route = ' root :to => "visitors#index"'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_apps_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Kehoe
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/generators/clean/gemfile_generator.rb
|
58
58
|
- lib/generators/clean/routes_generator.rb
|
59
59
|
- lib/generators/pages/authorized/authorized_generator.rb
|
60
|
+
- lib/generators/pages/authorized/templates/user_policy.rb
|
60
61
|
- lib/generators/pages/authorized/templates/users/_user.html.erb
|
61
62
|
- lib/generators/pages/authorized/templates/users/index.html.erb
|
62
63
|
- lib/generators/pages/authorized/templates/users/show.html.erb
|