rails_apps_pages 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd7aa409a98a87382e944567d542cc1f22e59720
4
- data.tar.gz: 56cd6f32c0c2ec03a4710fbc6ed859531607622b
3
+ metadata.gz: 7f7f7b2062c44981775c944d658214738a2d5ac1
4
+ data.tar.gz: 7b2bdcdd33b5f7a128f00aa96e0ef534b271978d
5
5
  SHA512:
6
- metadata.gz: b83d705dcb4454e01d9448bb05fc1fc70c275a54fd66cb51fc99579a5d99334a9c8af7a68fbcc729753772951db5c7e1033dc9f477e1b4cb91ee8b9b014a7eca
7
- data.tar.gz: 5b99723f79f1a121936291d57632d61d1a107f5b1125bb3345237379d8c710d9bee95322b5ca6f8af8fa850b4ef2983ad96eeb3195096ad5cfeb913f9c19f0f9
6
+ metadata.gz: 44d6965b93a1e66b630fa6a97b1e582a4bc8b7f63e02721b99d91c1957934e485210eec489489339581781f42e72e25a4ac6e046d629dedb167965ee874ac7d9
7
+ data.tar.gz: 6142bb9bf917bc5181736a6e0528042c481a6d93b64bdf5408deabfddd86c031beca88ce8d57ecae554b5dda6b527ceae79a0a9622287958f56907fe6d5f908e
data/CHANGELOG.textile CHANGED
@@ -1,5 +1,9 @@
1
1
  h1. CHANGELOG
2
2
 
3
+ h3. 0.4.3 May 10, 2014
4
+
5
+ * use Devise 'lazy way' to add name attribute to permitted parameters
6
+
3
7
  h3. 0.4.2 May 10, 2014
4
8
 
5
9
  * additional 'devise' tags for RSpec tests
@@ -0,0 +1,8 @@
1
+ before_action :configure_permitted_parameters, if: :devise_controller?
2
+
3
+ protected
4
+
5
+ def configure_permitted_parameters
6
+ devise_parameter_sanitizer.for(:sign_up) << :name
7
+ devise_parameter_sanitizer.for(:account_update) << :name
8
+ end
@@ -15,12 +15,21 @@ module Pages
15
15
  copy_file 'users_controller.rb', 'app/controllers/users_controller.rb'
16
16
  route = ' resources :users'
17
17
  inject_into_file 'config/routes.rb', route + "\n", :after => "devise_for :users\n"
18
- copy_file 'registrations_controller.rb', 'app/controllers/registrations_controller.rb'
19
- gsub_file 'config/routes.rb', /devise_for :users/, 'devise_for :users, :controllers => {:registrations => "registrations"}'
20
18
  generate 'pages:home -f'
21
19
  copy_file 'visitors/index.html.erb', 'app/views/visitors/index.html.erb'
22
20
  end
23
21
 
22
+ def add_name_field
23
+ if Object.const_defined?('User')
24
+ if User.column_names.include? 'name'
25
+ permitted = File.read(find_in_source_paths('permitted_parameters.rb'))
26
+ 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"
28
+ inject_into_file 'app/views/users/show.html.erb', "\n<p>Name: <%= @user.name if @user.name %></p>", :before => "\n<p>Email"
29
+ end
30
+ end
31
+ end
32
+
24
33
  def add_tests
25
34
  return unless File.exists?('spec/spec_helper.rb')
26
35
  copy_file 'spec/factories/users.rb', 'spec/factories/users.rb'
@@ -1,3 +1,3 @@
1
1
  module RailsAppsPages
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
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.2
4
+ version: 0.4.3
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-10 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,7 +67,7 @@ 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/registrations_controller.rb
70
+ - lib/generators/pages/users/templates/permitted_parameters.rb
71
71
  - lib/generators/pages/users/templates/spec/factories/users.rb
72
72
  - lib/generators/pages/users/templates/spec/features/users/sign_in_spec.rb
73
73
  - lib/generators/pages/users/templates/spec/features/users/sign_out_spec.rb
@@ -1,9 +0,0 @@
1
- class RegistrationsController < Devise::RegistrationsController
2
- before_filter :update_sanitized_params, if: :devise_controller?
3
-
4
- def update_sanitized_params
5
- devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)}
6
- devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :email, :password, :password_confirmation, :current_password)}
7
- end
8
-
9
- end