prologue 0.1.1 → 0.1.2

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.
@@ -1,3 +1,3 @@
1
1
  module Prologue
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -34,6 +34,9 @@ end
34
34
 
35
35
  inject_into_file 'app/controllers/admin/users_controller.rb', :after => "def update\n" do
36
36
  <<-'FILE'
37
+ params[:user].delete(:password) if params[:user][:password].blank?
38
+ params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
39
+
37
40
  if @user.update_attributes(params[:user])
38
41
  flash[:notice] = "Successfully updated #{@user.name}."
39
42
  redirect_to admin_users_url
@@ -57,6 +57,9 @@ apply File.expand_path("../db_seed.rb", __FILE__)
57
57
  # Make a home controller
58
58
  apply File.expand_path("../home_controller.rb", __FILE__)
59
59
 
60
+ # Make initializers
61
+ apply File.expand_path("../initializers.rb", __FILE__)
62
+
60
63
  # Clean up generated routes
61
64
  apply File.expand_path("../clean_routes.rb", __FILE__)
62
65
 
data/templates/cancan.rb CHANGED
@@ -84,6 +84,26 @@ if ENV['PROLOGUE_ADMIN']
84
84
  = role.name.humanize
85
85
  RUBY
86
86
  end
87
+
88
+ inject_into_file 'app/controllers/admin/users_controller.rb', :after => "@user = User.new(params[:user])\n" do
89
+ <<-'RUBY'
90
+ @user.role_ids = params[:user][:role_ids] if current_user.role? :admin
91
+ RUBY
92
+ end
93
+
94
+ inject_into_file 'app/controllers/admin/users_controller.rb', :before => "if @user.update_attributes(params[:user])\n" do
95
+ <<-'RUBY'
96
+ @user.send(:attributes=, { :role_ids => params[:user][:role_ids] }, false) if current_user.role? :admin
97
+ params[:user].delete(:role_ids)
98
+
99
+ RUBY
100
+ end
101
+
102
+ inject_into_file 'app/controllers/admin/users_controller.rb', :after => "def update\n" do
103
+ <<-'RUBY'
104
+ params[:user][:role_ids] ||= []
105
+ RUBY
106
+ end
87
107
  end
88
108
 
89
109
  append_file 'db/seeds.rb' do
@@ -0,0 +1,6 @@
1
+ create_file 'config/initializers/active_record.rb' do
2
+ <<-'FILE'
3
+ # This forces you to set attr_accessible in all your models
4
+ ActiveRecord::Base.send(:attr_accessible, nil)
5
+ FILE
6
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Quick Left
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-19 00:00:00 -06:00
17
+ date: 2010-10-20 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -145,6 +145,7 @@ files:
145
145
  - templates/gemfile.rb
146
146
  - templates/haml_generator.rb
147
147
  - templates/home_controller.rb
148
+ - templates/initializers.rb
148
149
  - templates/jammit.rb
149
150
  - templates/js.rb
150
151
  - templates/rails_clean.rb
@@ -184,6 +185,6 @@ rubyforge_project: prologue
184
185
  rubygems_version: 1.3.7
185
186
  signing_key:
186
187
  specification_version: 3
187
- summary: prologue-0.1.1
188
+ summary: prologue-0.1.2
188
189
  test_files: []
189
190