active_leonardo 0.1.0 → 0.2.0
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 +7 -0
- data/CHANGELOG.md +44 -0
- data/LICENSE +19 -19
- data/README.md +173 -0
- data/active_template.rb +141 -137
- data/lib/generators/active_leonardo.rb +7 -1
- data/lib/generators/erb/leosca/leosca_generator.rb +122 -122
- data/lib/generators/leolay/USAGE +21 -21
- data/lib/generators/leolay/leolay_generator.rb +420 -400
- data/lib/generators/leolay/templates/app/admin/users.rb +87 -87
- data/lib/generators/leolay/templates/config/locales/it.yml +7 -0
- data/lib/generators/leolay/templates/spec/helpers/application_helpers.rb +13 -13
- data/lib/generators/leolay/templates/spec/support/devise.rb +4 -4
- data/lib/generators/leolay/templates/styles/active/stylesheets/app/custom_active_admin.css.scss +27 -27
- data/lib/generators/leosca/USAGE +23 -23
- data/lib/generators/rails/leosca/USAGE +39 -39
- data/lib/generators/rails/leosca/leosca_generator.rb +55 -55
- data/lib/generators/rails/leosca/templates/leosca.css +56 -56
- data/lib/generators/rails/leosca_controller/USAGE +23 -23
- data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +192 -188
- data/lib/generators/rails/leosca_controller/templates/controller.rb +3 -3
- data/lib/generators/rspec/leointegration/leointegration_generator.rb +35 -35
- data/lib/generators/rspec/leointegration/templates/admin/feature.rb +67 -67
- data/lib/generators/rspec/leointegration/templates/feature.rb +9 -9
- data/lib/generators/rspec/leosca/leosca_generator.rb +57 -57
- data/lib/generators/rspec/leosca/templates/admin/controller_spec.rb +181 -181
- data/lib/generators/rspec/leosca/templates/admin/edit_spec.rb +31 -31
- data/lib/generators/rspec/leosca/templates/admin/index_spec.rb +32 -32
- data/lib/generators/rspec/leosca/templates/admin/new_spec.rb +30 -30
- data/lib/generators/rspec/leosca/templates/admin/routing_spec.rb +39 -39
- data/lib/generators/rspec/leosca/templates/admin/show_spec.rb +28 -28
- data/lib/generators/rspec/leosca/templates/controller_spec.rb +168 -168
- data/lib/generators/rspec/leosca/templates/edit_spec.rb +31 -31
- data/lib/generators/rspec/leosca/templates/index_spec.rb +32 -32
- data/lib/generators/rspec/leosca/templates/new_spec.rb +30 -30
- data/lib/generators/rspec/leosca/templates/routing_spec.rb +39 -39
- data/lib/generators/rspec/leosca/templates/show_spec.rb +28 -28
- metadata +55 -124
- data/CHANGELOG +0 -28
- data/README.rdoc +0 -159
@@ -1,56 +1,56 @@
|
|
1
|
-
body { background-color: #fff; color: #333; }
|
2
|
-
|
3
|
-
body, p, ol, ul, td {
|
4
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
-
font-size: 13px;
|
6
|
-
line-height: 18px;
|
7
|
-
}
|
8
|
-
|
9
|
-
pre {
|
10
|
-
background-color: #eee;
|
11
|
-
padding: 10px;
|
12
|
-
font-size: 11px;
|
13
|
-
}
|
14
|
-
|
15
|
-
a { color: #000; }
|
16
|
-
a:visited { color: #666; }
|
17
|
-
a:hover { color: #fff; background-color:#000; }
|
18
|
-
|
19
|
-
div.field, div.actions {
|
20
|
-
margin-bottom: 10px;
|
21
|
-
}
|
22
|
-
|
23
|
-
#notice {
|
24
|
-
color: green;
|
25
|
-
}
|
26
|
-
|
27
|
-
.field_with_errors {
|
28
|
-
padding: 2px;
|
29
|
-
background-color: red;
|
30
|
-
display: table;
|
31
|
-
}
|
32
|
-
|
33
|
-
#error_explanation {
|
34
|
-
width: 450px;
|
35
|
-
border: 2px solid red;
|
36
|
-
padding: 7px;
|
37
|
-
padding-bottom: 0;
|
38
|
-
margin-bottom: 20px;
|
39
|
-
background-color: #f0f0f0;
|
40
|
-
}
|
41
|
-
|
42
|
-
#error_explanation h2 {
|
43
|
-
text-align: left;
|
44
|
-
font-weight: bold;
|
45
|
-
padding: 5px 5px 5px 15px;
|
46
|
-
font-size: 12px;
|
47
|
-
margin: -7px;
|
48
|
-
margin-bottom: 0px;
|
49
|
-
background-color: #c00;
|
50
|
-
color: #fff;
|
51
|
-
}
|
52
|
-
|
53
|
-
#error_explanation ul li {
|
54
|
-
font-size: 12px;
|
55
|
-
list-style: square;
|
56
|
-
}
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
Description:
|
2
|
-
en: Customized version of rails's scaffold_controller, to be used after leolay.
|
3
|
-
it: Versione personalizzata dello scaffold_controller di rails, da usare dopo leolay.
|
4
|
-
|
5
|
-
Stubs out a scaffolded controller and its views. Pass the model name,
|
6
|
-
either CamelCased or under_scored, and a list of views as arguments.
|
7
|
-
The controller name is retrieved as a pluralized version of the model
|
8
|
-
name.
|
9
|
-
|
10
|
-
To create a controller within a module, specify the model name as a
|
11
|
-
path like 'parent_module/controller_name'.
|
12
|
-
|
13
|
-
This generates a controller class in app/controllers and invokes helper,
|
14
|
-
template engine and test framework generators.
|
15
|
-
|
16
|
-
Example:
|
17
|
-
`rails generate leosca_controller CreditCard`
|
18
|
-
|
19
|
-
Credit card controller with URLs like /credit_card/debit.
|
20
|
-
Controller: app/controllers/credit_cards_controller.rb
|
21
|
-
Functional Test: test/functional/credit_cards_controller_test.rb
|
22
|
-
Views: app/views/credit_cards/index.html.erb [...]
|
23
|
-
Helper: app/helpers/credit_cards_helper.rb
|
1
|
+
Description:
|
2
|
+
en: Customized version of rails's scaffold_controller, to be used after leolay.
|
3
|
+
it: Versione personalizzata dello scaffold_controller di rails, da usare dopo leolay.
|
4
|
+
|
5
|
+
Stubs out a scaffolded controller and its views. Pass the model name,
|
6
|
+
either CamelCased or under_scored, and a list of views as arguments.
|
7
|
+
The controller name is retrieved as a pluralized version of the model
|
8
|
+
name.
|
9
|
+
|
10
|
+
To create a controller within a module, specify the model name as a
|
11
|
+
path like 'parent_module/controller_name'.
|
12
|
+
|
13
|
+
This generates a controller class in app/controllers and invokes helper,
|
14
|
+
template engine and test framework generators.
|
15
|
+
|
16
|
+
Example:
|
17
|
+
`rails generate leosca_controller CreditCard`
|
18
|
+
|
19
|
+
Credit card controller with URLs like /credit_card/debit.
|
20
|
+
Controller: app/controllers/credit_cards_controller.rb
|
21
|
+
Functional Test: test/functional/credit_cards_controller_test.rb
|
22
|
+
Views: app/views/credit_cards/index.html.erb [...]
|
23
|
+
Helper: app/helpers/credit_cards_helper.rb
|
@@ -1,188 +1,192 @@
|
|
1
|
-
require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
|
2
|
-
require File.join(File.dirname(__FILE__), '../../active_leonardo')
|
3
|
-
|
4
|
-
WINDOWS = (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
|
5
|
-
CRLF = WINDOWS ? "\r\n" : "\n"
|
6
|
-
|
7
|
-
module Rails
|
8
|
-
module Generators
|
9
|
-
class LeoscaControllerGenerator < ::Rails::Generators::ScaffoldControllerGenerator
|
10
|
-
include ::ActiveLeonardo::Base
|
11
|
-
include ::ActiveLeonardo::Leosca
|
12
|
-
#include ::Leonardo::Nested
|
13
|
-
#include ::Leonardo::Nested::Test
|
14
|
-
#puts 'rails:leosca_controller'
|
15
|
-
|
16
|
-
source_root File.expand_path('../templates', __FILE__)
|
17
|
-
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
18
|
-
class_option :seeds, :type => :boolean, :default => true, :desc => "Create seeds to run with rake db:seed"
|
19
|
-
class_option :seeds_elements, :type => :string, :default => "30", :desc => "Choose seeds elements", :banner => "NUMBER"
|
20
|
-
#class_option :remote, :type => :boolean, :default => true, :desc => "Enable ajax. You can also do later set remote to true into index view."
|
21
|
-
#class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
|
22
|
-
#class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
23
|
-
class_option :auth_class, :type => :string, :default => 'User', :desc => "Set the authentication class name"
|
24
|
-
class_option :activeadmin, :type => :boolean, :default => true, :desc => "Add code to manage activeadmin gem"
|
25
|
-
|
26
|
-
#Override
|
27
|
-
def create_controller_files
|
28
|
-
template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
|
29
|
-
end
|
30
|
-
|
31
|
-
#Override
|
32
|
-
#hook_for :template_engine, :test_framework, :as => :leosca
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
files
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#content << "
|
51
|
-
#content << "
|
52
|
-
#content << "
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
#{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
#
|
95
|
-
can :read, #{class_name} if #{options[:auth_class].downcase}.role? :guest
|
96
|
-
if #{options[:auth_class].downcase}.role? :user
|
97
|
-
can [:read, :create], #{class_name}
|
98
|
-
can [:update, :destroy], #{class_name}
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
file
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#end
|
185
|
-
|
186
|
-
|
187
|
-
end
|
188
|
-
end
|
1
|
+
require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
|
2
|
+
require File.join(File.dirname(__FILE__), '../../active_leonardo')
|
3
|
+
|
4
|
+
WINDOWS = (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
|
5
|
+
CRLF = WINDOWS ? "\r\n" : "\n"
|
6
|
+
|
7
|
+
module Rails
|
8
|
+
module Generators
|
9
|
+
class LeoscaControllerGenerator < ::Rails::Generators::ScaffoldControllerGenerator
|
10
|
+
include ::ActiveLeonardo::Base
|
11
|
+
include ::ActiveLeonardo::Leosca
|
12
|
+
#include ::Leonardo::Nested
|
13
|
+
#include ::Leonardo::Nested::Test
|
14
|
+
#puts 'rails:leosca_controller'
|
15
|
+
|
16
|
+
source_root File.expand_path('../templates', __FILE__)
|
17
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
18
|
+
class_option :seeds, :type => :boolean, :default => true, :desc => "Create seeds to run with rake db:seed"
|
19
|
+
class_option :seeds_elements, :type => :string, :default => "30", :desc => "Choose seeds elements", :banner => "NUMBER"
|
20
|
+
#class_option :remote, :type => :boolean, :default => true, :desc => "Enable ajax. You can also do later set remote to true into index view."
|
21
|
+
#class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
|
22
|
+
#class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
23
|
+
class_option :auth_class, :type => :string, :default => 'User', :desc => "Set the authentication class name"
|
24
|
+
class_option :activeadmin, :type => :boolean, :default => true, :desc => "Add code to manage activeadmin gem"
|
25
|
+
|
26
|
+
#Override
|
27
|
+
def create_controller_files
|
28
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
|
29
|
+
end
|
30
|
+
|
31
|
+
#Override
|
32
|
+
#hook_for :template_engine, :test_framework, :as => :leosca
|
33
|
+
|
34
|
+
def update_yaml_locales
|
35
|
+
#Inject model and attributes name into yaml files for i18n
|
36
|
+
path = "config/locales"
|
37
|
+
files = Dir["#{path}/??.yml"]
|
38
|
+
files.each do |file|
|
39
|
+
|
40
|
+
next unless File.exists?(file)
|
41
|
+
|
42
|
+
#Fields name
|
43
|
+
inject_into_file file, :after => "#Attributes zone - do not remove" do
|
44
|
+
content = "#{CRLF} #{file_name}:#{CRLF}"
|
45
|
+
attributes.each do |attribute|
|
46
|
+
content << " #{attribute.name}: \"#{attribute.name.humanize}\"#{CRLF}"
|
47
|
+
end
|
48
|
+
#content << " op_new: \"New #{singular_table_name}\"#{CRLF}"
|
49
|
+
#content << " op_edit: \"Editing #{singular_table_name}\"#{CRLF}"
|
50
|
+
#content << " op_edit_multiple: \"Editing #{plural_table_name}\"#{CRLF}"
|
51
|
+
#content << " op_copy: \"Creating new #{plural_table_name}\"#{CRLF}"
|
52
|
+
#content << " op_index: \"Listing #{plural_table_name}\"#{CRLF}"
|
53
|
+
content
|
54
|
+
end
|
55
|
+
|
56
|
+
#Model name
|
57
|
+
inject_into_file file, :after => "models: &models" do
|
58
|
+
<<-FILE.gsub(/^ /, '')
|
59
|
+
|
60
|
+
#{file_name}: "#{file_name.capitalize}"
|
61
|
+
#{controller_name}: "#{controller_name.capitalize}"
|
62
|
+
FILE
|
63
|
+
end
|
64
|
+
|
65
|
+
#Formtastic
|
66
|
+
inject_into_file file, :after => " hints:" do
|
67
|
+
content = "#{CRLF} #{file_name}:#{CRLF}"
|
68
|
+
attributes.each do |attribute|
|
69
|
+
attr_name = attribute.name.humanize
|
70
|
+
case attribute.type
|
71
|
+
when :integer, :decimal, :float
|
72
|
+
content << " #{attribute.name}: \"Fill the #{attr_name} with a#{"n" if attribute.type == :integer} #{attribute.type.to_s} number\"#{CRLF}"
|
73
|
+
when :boolean
|
74
|
+
content << " #{attribute.name}: \"Select if this #{file_name} should be #{attr_name} or not\"#{CRLF}"
|
75
|
+
when :string, :text
|
76
|
+
content << " #{attribute.name}: \"Choose a good #{attr_name} for this #{file_name}\"#{CRLF}"
|
77
|
+
when :date, :datetime, :time, :timestamp
|
78
|
+
content << " #{attribute.name}: \"Choose a #{attribute.type.to_s} for #{attr_name}\"#{CRLF}"
|
79
|
+
else
|
80
|
+
content << " #{attribute.name}: \"Choose a #{attr_name}\"#{CRLF}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
content
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def update_ability_model
|
90
|
+
return unless authorization?
|
91
|
+
inject_into_file authorization_file, :before => " end\nend" do
|
92
|
+
<<-FILE.gsub(/^ /, '')
|
93
|
+
|
94
|
+
# ----- #{class_name.upcase} ----- #
|
95
|
+
can :read, #{class_name} if #{options[:auth_class].downcase}.role? :guest
|
96
|
+
if #{options[:auth_class].downcase}.role? :user
|
97
|
+
can [:read, :create], #{class_name}
|
98
|
+
can [:update, :destroy], #{class_name}
|
99
|
+
end
|
100
|
+
if #{options[:auth_class].downcase}.role? :manager
|
101
|
+
can [:read, :create, :update, :destroy], #{class_name}
|
102
|
+
end
|
103
|
+
|
104
|
+
FILE
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_seeds_db
|
109
|
+
return unless options.seeds? and options[:seeds_elements].to_i > 0
|
110
|
+
file = "db/seeds.rb"
|
111
|
+
append_file file do
|
112
|
+
items = []
|
113
|
+
attributes.each do |attribute|
|
114
|
+
items << attribute_to_hash(attribute)
|
115
|
+
end
|
116
|
+
row = "{ #{items.join(', ')} }"
|
117
|
+
|
118
|
+
#TODO: to have different values for every row
|
119
|
+
content = "#{CRLF}### Created by leosca controller generator ### #{CRLF}"
|
120
|
+
attributes.each do |attribute|
|
121
|
+
content << attribute_to_range(attribute)
|
122
|
+
end
|
123
|
+
content << "#{class_name}.create([#{CRLF}"
|
124
|
+
options[:seeds_elements].to_i.times do |n|
|
125
|
+
content << "#{row.gsub(/\#/, (n+1).to_s)},#{CRLF}"
|
126
|
+
end
|
127
|
+
content << "])#{CRLF}"
|
128
|
+
content
|
129
|
+
end if File.exists?(file)
|
130
|
+
end
|
131
|
+
|
132
|
+
def invoke_active_admin
|
133
|
+
return unless activeadmin? and options[:activeadmin]
|
134
|
+
#Rails::Generators.invoke("active_admin:resource", [singular_table_name])
|
135
|
+
invoke "active_admin:resource", [singular_table_name]
|
136
|
+
file = "app/admin/#{singular_table_name}.rb"
|
137
|
+
|
138
|
+
inject_into_file file, :after => "ActiveAdmin.register #{class_name} do" do
|
139
|
+
<<-FILE.gsub(/^ /, '')
|
140
|
+
|
141
|
+
menu :if => proc{ can?(:read, #{class_name}) }
|
142
|
+
|
143
|
+
permit_params do
|
144
|
+
permitted = [#{attributes.map{|attr| ":#{attr.name}"}.join(', ')}]
|
145
|
+
permitted
|
146
|
+
end
|
147
|
+
|
148
|
+
controller do
|
149
|
+
load_resource :except => :index
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
FILE
|
154
|
+
end if authorization? && File.exists?(file)
|
155
|
+
end
|
156
|
+
|
157
|
+
def update_specs
|
158
|
+
file = "spec/spec_helper.rb"
|
159
|
+
return unless File.exists? file
|
160
|
+
|
161
|
+
file = "spec/factories.rb"
|
162
|
+
inject_into_file file, :before => " ### Insert below here other your factories ###" do
|
163
|
+
items = []
|
164
|
+
attributes.each do |attribute|
|
165
|
+
items << attribute_to_factories(attribute)
|
166
|
+
end
|
167
|
+
<<-FILE.gsub(/^ /, '')
|
168
|
+
|
169
|
+
factory :#{singular_table_name} do |#{singular_table_name[0..0]}|
|
170
|
+
#{items.join(CRLF)}
|
171
|
+
end
|
172
|
+
FILE
|
173
|
+
end if File.exists?(file)
|
174
|
+
end
|
175
|
+
|
176
|
+
#def update_parent_controller
|
177
|
+
# return unless nested?
|
178
|
+
# file = "app/controllers/#{plural_last_parent}_controller.rb"
|
179
|
+
# inject_into_file file, :before => " private" do
|
180
|
+
# <<-FILE.gsub(/^ /, '')
|
181
|
+
# def with_#{plural_table_name}
|
182
|
+
# @#{last_parent} = #{last_parent.classify}.find params[:#{last_parent}_id]
|
183
|
+
# @#{plural_table_name} = #{class_name}.where(:#{last_parent}_id => params[:#{last_parent}_id])
|
184
|
+
# end
|
185
|
+
#
|
186
|
+
# FILE
|
187
|
+
# end if File.exists?(file)
|
188
|
+
#end
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|