rails_apps_pages 0.4.4 → 0.4.5
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/CHANGELOG.textile +4 -0
- data/README.textile +17 -0
- data/lib/generators/pages/users/templates/{permitted_parameters.rb → devise/permitted_parameters.rb} +0 -0
- data/lib/generators/pages/users/templates/{users_controller.rb → devise/users_controller.rb} +0 -0
- data/lib/generators/pages/users/templates/omniauth/users_controller.rb +32 -0
- data/lib/generators/pages/users/templates/users/edit.html.erb +10 -0
- data/lib/generators/pages/users/users_generator.rb +25 -10
- data/lib/rails_apps_pages/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4812f3289928d88a1abc76bc4285d48e485799c9
|
4
|
+
data.tar.gz: e45a51f5260d346d39de47cba297934819f9982f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65d1142719d88ec42322c0390a0951dcb581f8645fe833385495565cd23dd6fb24b6df14be1c73979d8aeda805e8a9e9007026a5385bd75bef2c4e6762303d2d
|
7
|
+
data.tar.gz: f1282e491104045fefadbbdb0dc6e969e13ea0a82be5b8738695d19ec9ef2ead0b222038a560e5dfe6f0b1f33863715db4607aa30214a2acb2cdedd43ccbd807
|
data/CHANGELOG.textile
CHANGED
data/README.textile
CHANGED
@@ -156,3 +156,20 @@ h2. MIT License
|
|
156
156
|
"MIT License":http://www.opensource.org/licenses/mit-license
|
157
157
|
|
158
158
|
Copyright © 2014 Daniel Kehoe
|
159
|
+
|
160
|
+
h2. Useful Links
|
161
|
+
|
162
|
+
|_. Getting Started |_. Articles |_. Tutorials |
|
163
|
+
| "Ruby on Rails":http://railsapps.github.io/ruby-and-rails.html | "Analytics for Rails":http://railsapps.github.io/rails-google-analytics.html | "Rails Bootstrap":http://railsapps.github.io/twitter-bootstrap-rails.html |
|
164
|
+
| "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html | "Heroku and Rails":http://railsapps.github.io/rails-heroku-tutorial.html | "Rails Foundation":http://railsapps.github.io/rails-foundation.html |
|
165
|
+
| "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html | "JavaScript and Rails":http://railsapps.github.io/rails-javascript-include-external.html | "RSpec Tutorial":http://railsapps.github.io/rspec.html |
|
166
|
+
| "Rails Tutorial":https://tutorials.railsapps.org/rails-tutorial | "Rails Environment Variables":http://railsapps.github.io/rails-environment-variables.html | "Rails Devise Tutorial":http://railsapps.github.io/tutorial-rails-devise.html |
|
167
|
+
| "Ruby on Rails Tutorial for Beginners":http://learn-rails.com/ruby-on-rails-tutorial-for-beginners | "Git and GitHub with Rails":http://railsapps.github.io/rails-git.html | "Devise RSpec":http://railsapps.github.io/tutorial-rails-devise-rspec-cucumber.html |
|
168
|
+
| "Install Ruby on Rails":http://railsapps.github.io/installing-rails.html | "Send Email with Rails":http://railsapps.github.io/rails-send-email.html | "Devise Bootstrap":http://railsapps.github.io/tutorial-rails-bootstrap-devise-cancan.html |
|
169
|
+
| "Install Ruby on Rails - Mac OS X":http://railsapps.github.io/installrubyonrails-mac.html | "Haml and Rails":http://railsapps.github.io/rails-haml.html | "Rails Membership Site with Stripe":https://tutorials.railsapps.org/rails-stripe-membership-saas |
|
170
|
+
| "Install Ruby on Rails - Ubuntu":http://railsapps.github.io/installrubyonrails-ubuntu.html | "Rails Application Layout":http://railsapps.github.io/rails-default-application-layout.html | "Rails Subscription Site with Recurly":https://tutorials.railsapps.org/rails-recurly-subscription-saas |
|
171
|
+
| "Ruby on Rails - Nitrous.io":http://railsapps.github.io/rubyonrails-nitrous-io.html | "HTML5 Boilerplate for Rails":http://railsapps.github.io/rails-html5-boilerplate.html | "Startup Prelaunch Signup Application":https://tutorials.railsapps.org/rails-prelaunch-signup |
|
172
|
+
| "Update Rails":http://railsapps.github.io/updating-rails.html | "Example Gemfiles for Rails":http://railsapps.github.io/rails-3-2-example-gemfile.html |
|
173
|
+
| "Rails Composer":http://railsapps.github.io/rails-composer/ | "Rails Application Templates":http://railsapps.github.io/rails-application-templates.html |
|
174
|
+
| "Rails Examples":http://railsapps.github.io/ | "Rails Product Planning":http://railsapps.github.io/rails-product-planning.html |
|
175
|
+
| "Rails Starter Apps":http://railsapps.github.io/rails-examples-tutorials.html | "Rails Project Management":http://railsapps.github.io/rails-project-management.html |
|
data/lib/generators/pages/users/templates/{permitted_parameters.rb → devise/permitted_parameters.rb}
RENAMED
File without changes
|
data/lib/generators/pages/users/templates/{users_controller.rb → devise/users_controller.rb}
RENAMED
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
before_filter :authenticate_user!
|
3
|
+
before_filter :correct_user?, :except => [:index]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@users = User.all
|
7
|
+
end
|
8
|
+
|
9
|
+
def edit
|
10
|
+
@user = User.find(params[:id])
|
11
|
+
end
|
12
|
+
|
13
|
+
def update
|
14
|
+
@user = User.find(params[:id])
|
15
|
+
if @user.update_attributes(secure_params)
|
16
|
+
redirect_to @user
|
17
|
+
else
|
18
|
+
render :edit
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def show
|
23
|
+
@user = User.find(params[:id])
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def secure_params
|
29
|
+
params.require(:user).permit(:email)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -5,32 +5,47 @@ module Pages
|
|
5
5
|
class UsersGenerator < ::Rails::Generators::Base
|
6
6
|
source_root File.expand_path("../templates", __FILE__)
|
7
7
|
|
8
|
-
desc "Create pages to accompany a User model
|
8
|
+
desc "Create pages to accompany a User model."
|
9
9
|
|
10
|
-
def
|
11
|
-
### assumes we are using Devise for authentication
|
10
|
+
def create_pages
|
12
11
|
copy_file 'users/_user.html.erb', 'app/views/users/_user.html.erb'
|
13
12
|
copy_file 'users/index.html.erb', 'app/views/users/index.html.erb'
|
14
13
|
copy_file 'users/show.html.erb', 'app/views/users/show.html.erb'
|
15
|
-
copy_file 'users_controller.rb', 'app/controllers/users_controller.rb'
|
16
|
-
route = ' resources :users'
|
17
|
-
inject_into_file 'config/routes.rb', route + "\n", :after => "devise_for :users\n"
|
18
14
|
generate 'pages:home -f'
|
19
15
|
copy_file 'visitors/index.html.erb', 'app/views/visitors/index.html.erb'
|
20
16
|
end
|
21
17
|
|
22
|
-
def
|
18
|
+
def create_devise_pages
|
19
|
+
return unless File.exists?('config/initializers/devise.rb')
|
20
|
+
copy_file 'devise/users_controller.rb', 'app/controllers/users_controller.rb'
|
21
|
+
route = ' resources :users'
|
22
|
+
inject_into_file 'config/routes.rb', route + "\n", :after => "devise_for :users\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_omniauth_pages
|
26
|
+
return unless File.exists?('config/initializers/omniauth.rb')
|
27
|
+
copy_file 'users/edit.html.erb', 'app/views/users/edit.html.erb'
|
28
|
+
copy_file 'omniauth/users_controller.rb', 'app/controllers/users_controller.rb'
|
29
|
+
route = ' resources :users, :only => [:index, :show, :edit, :update ]'
|
30
|
+
inject_into_file 'config/routes.rb', route + "\n", :after => "root :to => \"visitors#index\"\n"
|
31
|
+
prepend_file 'app/views/users/_user.html.erb', "<td><%= link_to user.name, user %></td>\n"
|
32
|
+
inject_into_file 'app/views/users/show.html.erb', "\n<p>Name: <%= @user.name if @user.name %></p>", :before => "\n<p>Email"
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_devise_name_field
|
36
|
+
return unless File.exists?('config/initializers/devise.rb')
|
23
37
|
if Object.const_defined?('User')
|
24
38
|
if User.column_names.include? 'name'
|
25
|
-
permitted = File.read(find_in_source_paths('permitted_parameters.rb'))
|
39
|
+
permitted = File.read(find_in_source_paths('devise/permitted_parameters.rb'))
|
26
40
|
inject_into_file 'app/controllers/application_controller.rb', permitted + "\n", :after => "protect_from_forgery with: :exception\n"
|
27
|
-
prepend_file 'app/views/users/_user.html.erb', "<td><%= user.name %></td>\n"
|
41
|
+
prepend_file 'app/views/users/_user.html.erb', "<td><%= link_to user.name, user %></td>\n"
|
28
42
|
inject_into_file 'app/views/users/show.html.erb', "\n<p>Name: <%= @user.name if @user.name %></p>", :before => "\n<p>Email"
|
29
43
|
end
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
33
|
-
def
|
47
|
+
def add_devise_tests
|
48
|
+
return unless File.exists?('config/initializers/devise.rb')
|
34
49
|
return unless File.exists?('spec/spec_helper.rb')
|
35
50
|
copy_file 'spec/factories/users.rb', 'spec/factories/users.rb'
|
36
51
|
copy_file 'spec/features/users/sign_in_spec.rb', 'spec/features/users/sign_in_spec.rb'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_apps_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Kehoe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,7 +67,9 @@ files:
|
|
67
67
|
- lib/generators/pages/home/templates/home_page_spec.rb
|
68
68
|
- lib/generators/pages/home/templates/index.html.erb
|
69
69
|
- lib/generators/pages/home/templates/visitors_controller.rb
|
70
|
-
- lib/generators/pages/users/templates/permitted_parameters.rb
|
70
|
+
- lib/generators/pages/users/templates/devise/permitted_parameters.rb
|
71
|
+
- lib/generators/pages/users/templates/devise/users_controller.rb
|
72
|
+
- lib/generators/pages/users/templates/omniauth/users_controller.rb
|
71
73
|
- lib/generators/pages/users/templates/spec/factories/users.rb
|
72
74
|
- lib/generators/pages/users/templates/spec/features/users/sign_in_spec.rb
|
73
75
|
- lib/generators/pages/users/templates/spec/features/users/sign_out_spec.rb
|
@@ -80,9 +82,9 @@ files:
|
|
80
82
|
- lib/generators/pages/users/templates/spec/support/helpers.rb
|
81
83
|
- lib/generators/pages/users/templates/spec/support/helpers/session_helpers.rb
|
82
84
|
- lib/generators/pages/users/templates/users/_user.html.erb
|
85
|
+
- lib/generators/pages/users/templates/users/edit.html.erb
|
83
86
|
- lib/generators/pages/users/templates/users/index.html.erb
|
84
87
|
- lib/generators/pages/users/templates/users/show.html.erb
|
85
|
-
- lib/generators/pages/users/templates/users_controller.rb
|
86
88
|
- lib/generators/pages/users/templates/visitors/index.html.erb
|
87
89
|
- lib/generators/pages/users/users_generator.rb
|
88
90
|
- lib/rails_apps_pages.rb
|