nifty-generators 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. data/CHANGELOG +7 -0
  2. data/Gemfile.lock +59 -57
  3. data/README.rdoc +7 -0
  4. data/features/nifty_scaffold.feature +30 -0
  5. data/features/step_definitions/common_steps.rb +6 -0
  6. data/lib/generators/nifty/scaffold/scaffold_generator.rb +93 -23
  7. data/lib/generators/nifty/scaffold/templates/actions/create.rb +4 -4
  8. data/lib/generators/nifty/scaffold/templates/actions/destroy.rb +4 -4
  9. data/lib/generators/nifty/scaffold/templates/actions/edit.rb +1 -1
  10. data/lib/generators/nifty/scaffold/templates/actions/index.rb +1 -1
  11. data/lib/generators/nifty/scaffold/templates/actions/new.rb +1 -1
  12. data/lib/generators/nifty/scaffold/templates/actions/show.rb +1 -1
  13. data/lib/generators/nifty/scaffold/templates/actions/update.rb +4 -4
  14. data/lib/generators/nifty/scaffold/templates/migration.rb +3 -3
  15. data/lib/generators/nifty/scaffold/templates/model.rb +1 -0
  16. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb +4 -4
  17. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb +4 -4
  18. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb +4 -4
  19. data/lib/generators/nifty/scaffold/templates/views/erb/_form.html.erb +1 -1
  20. data/lib/generators/nifty/scaffold/templates/views/erb/edit.html.erb +2 -2
  21. data/lib/generators/nifty/scaffold/templates/views/erb/index.html.erb +6 -6
  22. data/lib/generators/nifty/scaffold/templates/views/erb/new.html.erb +1 -1
  23. data/lib/generators/nifty/scaffold/templates/views/erb/show.html.erb +4 -4
  24. data/lib/generators/nifty/scaffold/templates/views/haml/_form.html.haml +1 -1
  25. data/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml +2 -2
  26. data/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml +6 -6
  27. data/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml +1 -1
  28. data/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml +4 -4
  29. metadata +3 -3
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.4.4 (January 17, 2011)
2
+
3
+ * adding namespaces to nifty:scaffold (thanks DouglasMeyer) - issue #63
4
+
5
+ * adding .rvmrc file
6
+
7
+
1
8
  0.4.3 (December 28, 2010)
2
9
 
3
10
  * display usage documentation when given an invalid model name with nifty:scaffold - issue #76
@@ -7,40 +7,39 @@ GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  abstract (1.0.0)
10
- actionmailer (3.0.1)
11
- actionpack (= 3.0.1)
12
- mail (~> 2.2.5)
13
- actionpack (3.0.1)
14
- activemodel (= 3.0.1)
15
- activesupport (= 3.0.1)
10
+ actionmailer (3.0.3)
11
+ actionpack (= 3.0.3)
12
+ mail (~> 2.2.9)
13
+ actionpack (3.0.3)
14
+ activemodel (= 3.0.3)
15
+ activesupport (= 3.0.3)
16
16
  builder (~> 2.1.2)
17
17
  erubis (~> 2.6.6)
18
- i18n (~> 0.4.1)
18
+ i18n (~> 0.4)
19
19
  rack (~> 1.2.1)
20
- rack-mount (~> 0.6.12)
21
- rack-test (~> 0.5.4)
20
+ rack-mount (~> 0.6.13)
21
+ rack-test (~> 0.5.6)
22
22
  tzinfo (~> 0.3.23)
23
- activemodel (3.0.1)
24
- activesupport (= 3.0.1)
23
+ activemodel (3.0.3)
24
+ activesupport (= 3.0.3)
25
25
  builder (~> 2.1.2)
26
- i18n (~> 0.4.1)
27
- activerecord (3.0.1)
28
- activemodel (= 3.0.1)
29
- activesupport (= 3.0.1)
30
- arel (~> 1.0.0)
26
+ i18n (~> 0.4)
27
+ activerecord (3.0.3)
28
+ activemodel (= 3.0.3)
29
+ activesupport (= 3.0.3)
30
+ arel (~> 2.0.2)
31
31
  tzinfo (~> 0.3.23)
32
- activeresource (3.0.1)
33
- activemodel (= 3.0.1)
34
- activesupport (= 3.0.1)
35
- activesupport (3.0.1)
36
- arel (1.0.1)
37
- activesupport (~> 3.0.0)
38
- bcrypt-ruby (2.1.2)
32
+ activeresource (3.0.3)
33
+ activemodel (= 3.0.3)
34
+ activesupport (= 3.0.3)
35
+ activesupport (3.0.3)
36
+ arel (2.0.7)
37
+ bcrypt-ruby (2.1.4)
39
38
  builder (2.1.2)
40
- cucumber (0.9.2)
39
+ cucumber (0.9.4)
41
40
  builder (~> 2.1.2)
42
41
  diff-lcs (~> 1.1.2)
43
- gherkin (~> 2.2.5)
42
+ gherkin (~> 2.2.9)
44
43
  json (~> 1.4.6)
45
44
  term-ansicolor (~> 1.0.5)
46
45
  diff-lcs (1.1.2)
@@ -49,53 +48,56 @@ GEM
49
48
  gherkin (2.2.9)
50
49
  json (~> 1.4.6)
51
50
  term-ansicolor (~> 1.0.5)
52
- i18n (0.4.1)
51
+ i18n (0.5.0)
53
52
  json (1.4.6)
54
- mail (2.2.7)
53
+ mail (2.2.14)
55
54
  activesupport (>= 2.3.6)
56
- mime-types
57
- treetop (>= 1.4.5)
55
+ i18n (>= 0.4.0)
56
+ mime-types (~> 1.16)
57
+ treetop (~> 1.4.8)
58
58
  mime-types (1.16)
59
- mocha (0.9.8)
59
+ mocha (0.9.10)
60
60
  rake
61
61
  polyglot (0.3.1)
62
62
  rack (1.2.1)
63
63
  rack-mount (0.6.13)
64
64
  rack (>= 1.0.0)
65
- rack-test (0.5.6)
65
+ rack-test (0.5.7)
66
66
  rack (>= 1.0)
67
- rails (3.0.1)
68
- actionmailer (= 3.0.1)
69
- actionpack (= 3.0.1)
70
- activerecord (= 3.0.1)
71
- activeresource (= 3.0.1)
72
- activesupport (= 3.0.1)
73
- bundler (~> 1.0.0)
74
- railties (= 3.0.1)
75
- railties (3.0.1)
76
- actionpack (= 3.0.1)
77
- activesupport (= 3.0.1)
78
- rake (>= 0.8.4)
79
- thor (~> 0.14.0)
67
+ rails (3.0.3)
68
+ actionmailer (= 3.0.3)
69
+ actionpack (= 3.0.3)
70
+ activerecord (= 3.0.3)
71
+ activeresource (= 3.0.3)
72
+ activesupport (= 3.0.3)
73
+ bundler (~> 1.0)
74
+ railties (= 3.0.3)
75
+ railties (3.0.3)
76
+ actionpack (= 3.0.3)
77
+ activesupport (= 3.0.3)
78
+ rake (>= 0.8.7)
79
+ thor (~> 0.14.4)
80
80
  rake (0.8.7)
81
- rspec (2.0.0)
82
- rspec-core (= 2.0.0)
83
- rspec-expectations (= 2.0.0)
84
- rspec-mocks (= 2.0.0)
85
- rspec-core (2.0.0)
86
- rspec-expectations (2.0.0)
81
+ rspec (2.0.1)
82
+ rspec-core (~> 2.0.1)
83
+ rspec-expectations (~> 2.0.1)
84
+ rspec-mocks (~> 2.0.1)
85
+ rspec-core (2.0.1)
86
+ rspec-expectations (2.0.1)
87
87
  diff-lcs (>= 1.1.2)
88
- rspec-mocks (2.0.0)
89
- rspec-core (= 2.0.0)
90
- rspec-expectations (= 2.0.0)
88
+ rspec-mocks (2.0.1)
89
+ rspec-core (~> 2.0.1)
90
+ rspec-expectations (~> 2.0.1)
91
91
  rspec-rails (2.0.1)
92
92
  rspec (~> 2.0.0)
93
- sqlite3-ruby (1.3.1)
93
+ sqlite3 (1.3.3)
94
+ sqlite3-ruby (1.3.3)
95
+ sqlite3 (>= 1.3.3)
94
96
  term-ansicolor (1.0.5)
95
- thor (0.14.3)
96
- treetop (1.4.8)
97
+ thor (0.14.6)
98
+ treetop (1.4.9)
97
99
  polyglot (>= 0.3.1)
98
- tzinfo (0.3.23)
100
+ tzinfo (0.3.24)
99
101
 
100
102
  PLATFORMS
101
103
  ruby
@@ -100,3 +100,10 @@ Also, make sure you're using Rails 2.1 or greater.
100
100
  If you are having a problem with Nifty Generators, first look at the FAQs above. If you still cannot resolve it, please submit an issue here.
101
101
 
102
102
  http://github.com/ryanb/nifty-generators/issues
103
+
104
+
105
+ == Development
106
+
107
+ If you want to contribute to this project, you can download the Git repository and get the Cucumber features running by calling +bundle+ then +rake+. I normally develop this using Ruby 1.9.2 however it should work with 1.8.7 as well.
108
+
109
+ The Rails 3 generators are located under <tt>lib/generators</tt> and are tested with Cucumber. The older Rails 2 generators are under <tt>rails_generators</tt> and are tested with Shoulda under the <tt>test</tt> directory.
@@ -42,3 +42,33 @@ Feature: Nifty Scaffold Generator
42
42
  Scenario: Report error when invalid model name
43
43
  Given a new Rails app
44
44
  Then I should see "Usage:" when running "rails g nifty:scaffold name:string parent_id:integer"
45
+
46
+ Scenario: Generate scaffold for namespaced resource
47
+ Given a new Rails app
48
+ When I run "rails g nifty:scaffold Admin::User name:string"
49
+ Then I should see the following files
50
+ | app/models/user.rb |
51
+ | app/controllers/admin/users_controller.rb |
52
+ | app/helpers/admin/users_helper.rb |
53
+ | app/views/admin/users/index.html.erb |
54
+ | app/views/admin/users/show.html.erb |
55
+ | app/views/admin/users/new.html.erb |
56
+ | app/views/admin/users/edit.html.erb |
57
+ | db/migrate |
58
+ And I should see "class User" in file "app/models/user.rb"
59
+ And I should not see "set_table_name :" in file "app/models/user.rb"
60
+ And I should see "namespace(:admin){ resources :users }" in file "config/routes.rb"
61
+ When I run "rails g nifty:layout -f"
62
+ And I run "rake db:migrate"
63
+ And I should successfully run "rails g nifty:scaffold Admin::User -f"
64
+ Then I should successfully run "rake test"
65
+
66
+ Scenario: Generate scaffold with a namespaced model
67
+ Given a new Rails app
68
+ When I run "rails g nifty:scaffold Admin::User name:string --namespace_model"
69
+ Then I should see "class Admin::User" in file "app/models/admin/user.rb"
70
+ And I should see "set_table_name :admin_users" in file "app/models/admin/user.rb"
71
+ When I run "rails g nifty:layout -f"
72
+ And I run "rake db:migrate"
73
+ And I should successfully run "rails g nifty:scaffold Admin::User -f --namespace_model"
74
+ Then I should successfully run "rake test"
@@ -25,6 +25,12 @@ Then /^I should see "(.*)" in file "([^\"]*)"$/ do |content, short_path|
25
25
  File.readlines(path).join.should include(content)
26
26
  end
27
27
 
28
+ Then /^I should not see "(.*)" in file "([^\"]*)"$/ do |content, short_path|
29
+ path = File.join(@current_directory, short_path)
30
+ File.should exist(path)
31
+ File.readlines(path).join.should_not include(content)
32
+ end
33
+
28
34
  Then /^I should see the following files$/ do |table|
29
35
  table.raw.flatten.each do |path|
30
36
  File.should exist(File.join(@current_directory, path))
@@ -6,9 +6,9 @@ module Nifty
6
6
  module Generators
7
7
  class ScaffoldGenerator < Base
8
8
  include Rails::Generators::Migration
9
- no_tasks { attr_accessor :model_name, :model_attributes, :controller_actions }
9
+ no_tasks { attr_accessor :scaffold_name, :model_attributes, :controller_actions }
10
10
 
11
- argument :model_name, :type => :string, :required => true, :banner => 'ModelName'
11
+ argument :scaffold_name, :type => :string, :required => true, :banner => 'ModelName'
12
12
  argument :args_for_c_m, :type => :array, :default => [], :banner => 'controller_actions and model:attributes'
13
13
 
14
14
  class_option :skip_model, :desc => 'Don\'t generate a model or migration file.', :type => :boolean
@@ -16,6 +16,7 @@ module Nifty
16
16
  class_option :skip_timestamps, :desc => 'Don\'t add timestamps to migration file.', :type => :boolean
17
17
  class_option :skip_controller, :desc => 'Don\'t generate controller, helper, or views.', :type => :boolean
18
18
  class_option :invert, :desc => 'Generate all controller actions except these mentioned.', :type => :boolean
19
+ class_option :namespace_model, :desc => 'If the resource is namespaced, include the model in the namespace.', :type => :boolean
19
20
  class_option :haml, :desc => 'Generate HAML views instead of ERB.', :type => :boolean
20
21
 
21
22
  class_option :testunit, :desc => 'Use test/unit for test files.', :group => 'Test framework', :type => :boolean
@@ -25,11 +26,12 @@ module Nifty
25
26
  def initialize(*args, &block)
26
27
  super
27
28
 
28
- print_usage unless model_name =~ /^[a-zA-Z_]+$/
29
+ print_usage unless scaffold_name.underscore =~ /^[a-z][a-z0-9_\/]+$/
29
30
 
30
31
  @controller_actions = []
31
32
  @model_attributes = []
32
33
  @skip_model = options.skip_model?
34
+ @namespace_model = options.namespace_model?
33
35
  @invert_actions = options.invert?
34
36
 
35
37
  args_for_c_m.each do |arg|
@@ -69,20 +71,20 @@ module Nifty
69
71
 
70
72
  def create_model
71
73
  unless @skip_model
72
- template 'model.rb', "app/models/#{singular_name}.rb"
74
+ template 'model.rb', "app/models/#{model_path}.rb"
73
75
  if test_framework == :rspec
74
- template "tests/rspec/model.rb", "spec/models/#{singular_name}_spec.rb"
75
- template 'fixtures.yml', "spec/fixtures/#{plural_name}.yml"
76
+ template "tests/rspec/model.rb", "spec/models/#{model_path}_spec.rb"
77
+ template 'fixtures.yml', "spec/fixtures/#{model_path.pluralize}.yml"
76
78
  else
77
- template "tests/#{test_framework}/model.rb", "test/unit/#{singular_name}_test.rb"
78
- template 'fixtures.yml', "test/fixtures/#{plural_name}.yml"
79
+ template "tests/#{test_framework}/model.rb", "test/unit/#{model_path}_test.rb"
80
+ template 'fixtures.yml', "test/fixtures/#{model_path.pluralize}.yml"
79
81
  end
80
82
  end
81
83
  end
82
84
 
83
85
  def create_migration
84
86
  unless @skip_model || options.skip_migration?
85
- migration_template 'migration.rb', "db/migrate/create_#{plural_name}.rb"
87
+ migration_template 'migration.rb', "db/migrate/create_#{model_path.pluralize.gsub('/', '_')}.rb"
86
88
  end
87
89
  end
88
90
 
@@ -102,7 +104,11 @@ module Nifty
102
104
  template "views/#{view_language}/_form.html.#{view_language}", "app/views/#{plural_name}/_form.html.#{view_language}"
103
105
  end
104
106
 
105
- route "resources #{plural_name.to_sym.inspect}"
107
+ namespaces = plural_name.split('/')
108
+ resource = namespaces.pop
109
+ route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
110
+ "namespace(:#{namespace}){ #{acc} }"
111
+ }
106
112
 
107
113
  if test_framework == :rspec
108
114
  template "tests/#{test_framework}/controller.rb", "spec/controllers/#{plural_name}_controller_spec.rb"
@@ -131,21 +137,47 @@ module Nifty
131
137
  end
132
138
 
133
139
  def singular_name
134
- model_name.underscore
140
+ scaffold_name.underscore
135
141
  end
136
142
 
137
143
  def plural_name
138
- model_name.underscore.pluralize
144
+ scaffold_name.underscore.pluralize
145
+ end
146
+
147
+ def table_name
148
+ if scaffold_name.include?('::') && @namespace_model
149
+ plural_name.gsub('/', '_')
150
+ end
139
151
  end
140
152
 
141
153
  def class_name
142
- model_name.camelize
154
+ if @namespace_model
155
+ scaffold_name.camelize
156
+ else
157
+ scaffold_name.split('::').last.camelize
158
+ end
159
+ end
160
+
161
+ def model_path
162
+ class_name.underscore
143
163
  end
144
164
 
145
165
  def plural_class_name
146
166
  plural_name.camelize
147
167
  end
148
168
 
169
+ def instance_name
170
+ if @namespace_model
171
+ singular_name.gsub('/','_')
172
+ else
173
+ singular_name.split('/').last
174
+ end
175
+ end
176
+
177
+ def instances_name
178
+ instance_name.pluralize
179
+ end
180
+
149
181
  def controller_methods(dir_name)
150
182
  controller_actions.map do |action|
151
183
  read_template("#{dir_name}/#{action}.rb")
@@ -164,35 +196,73 @@ module Nifty
164
196
  end
165
197
  end
166
198
 
167
- def items_path(suffix = 'path')
199
+ def item_resource
200
+ scaffold_name.underscore.gsub('/','_')
201
+ end
202
+
203
+ def items_path
168
204
  if action? :index
169
- "#{plural_name}_#{suffix}"
205
+ "#{item_resource.pluralize}_path"
206
+ else
207
+ "root_path"
208
+ end
209
+ end
210
+
211
+ def item_path(options = {})
212
+ if action? :show
213
+ name = options[:instance_variable] ? "@#{instance_name}" : instance_name
214
+ if %w(new edit).include? options[:action].to_s
215
+ "#{options[:action].to_s}_#{item_resource}_path(#{name})"
216
+ else
217
+ if scaffold_name.include?('::') && !@namespace_model
218
+ namespace = singular_name.split('/')[0..-2]
219
+ "[ :#{namespace.join(', :')}, #{name} ]"
220
+ else
221
+ name
222
+ end
223
+ end
170
224
  else
171
- "root_#{suffix}"
225
+ items_path
172
226
  end
173
227
  end
174
228
 
175
- def item_path(suffix = 'path')
229
+ def item_url
176
230
  if action? :show
177
- "@#{singular_name}"
231
+ item_resource + '_url'
232
+ else
233
+ items_url
234
+ end
235
+ end
236
+
237
+ def items_url
238
+ if action? :index
239
+ item_resource.pluralize + '_url'
178
240
  else
179
- items_path(suffix)
241
+ "root_url"
180
242
  end
181
243
  end
182
244
 
183
245
  def item_path_for_spec(suffix = 'path')
184
246
  if action? :show
185
- "#{singular_name}_#{suffix}(assigns[:#{singular_name}])"
247
+ "#{item_resource}_#{suffix}(assigns[:#{instance_name}])"
186
248
  else
187
- items_path(suffix)
249
+ if suffix == 'path'
250
+ items_path
251
+ else
252
+ items_url
253
+ end
188
254
  end
189
255
  end
190
256
 
191
257
  def item_path_for_test(suffix = 'path')
192
258
  if action? :show
193
- "#{singular_name}_#{suffix}(assigns(:#{singular_name}))"
259
+ "#{item_resource}_#{suffix}(assigns(:#{instance_name}))"
194
260
  else
195
- items_path(suffix)
261
+ if suffix == 'path'
262
+ items_path
263
+ else
264
+ items_url
265
+ end
196
266
  end
197
267
  end
198
268
 
@@ -1,8 +1,8 @@
1
1
  def create
2
- @<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])
3
- if @<%= singular_name %>.save
4
- flash[:notice] = "Successfully created <%= model_name.underscore.humanize.downcase %>."
5
- redirect_to <%= item_path('url') %>
2
+ @<%= instance_name %> = <%= class_name %>.new(params[:<%= instance_name %>])
3
+ if @<%= instance_name %>.save
4
+ flash[:notice] = "Successfully created <%= class_name.underscore.humanize.downcase %>."
5
+ redirect_to <%= item_path :instance_variable => true %>
6
6
  else
7
7
  render :action => 'new'
8
8
  end
@@ -1,6 +1,6 @@
1
1
  def destroy
2
- @<%= singular_name %> = <%= class_name %>.find(params[:id])
3
- @<%= singular_name %>.destroy
4
- flash[:notice] = "Successfully destroyed <%= model_name.underscore.humanize.downcase %>."
5
- redirect_to <%= items_path('url') %>
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ @<%= instance_name %>.destroy
4
+ flash[:notice] = "Successfully destroyed <%= class_name.underscore.humanize.downcase %>."
5
+ redirect_to <%= items_url %>
6
6
  end
@@ -1,3 +1,3 @@
1
1
  def edit
2
- @<%= singular_name %> = <%= class_name %>.find(params[:id])
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
3
  end
@@ -1,3 +1,3 @@
1
1
  def index
2
- @<%= plural_name %> = <%= class_name %>.all
2
+ @<%= instances_name %> = <%= class_name %>.all
3
3
  end
@@ -1,3 +1,3 @@
1
1
  def new
2
- @<%= singular_name %> = <%= class_name %>.new
2
+ @<%= instance_name %> = <%= class_name %>.new
3
3
  end
@@ -1,3 +1,3 @@
1
1
  def show
2
- @<%= singular_name %> = <%= class_name %>.find(params[:id])
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
3
  end
@@ -1,8 +1,8 @@
1
1
  def update
2
- @<%= singular_name %> = <%= class_name %>.find(params[:id])
3
- if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
4
- flash[:notice] = "Successfully updated <%= model_name.underscore.humanize.downcase %>."
5
- redirect_to <%= item_path('url') %>
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ if @<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
4
+ flash[:notice] = "Successfully updated <%= class_name.underscore.humanize.downcase %>."
5
+ redirect_to <%= item_url %>
6
6
  else
7
7
  render :action => 'edit'
8
8
  end
@@ -1,6 +1,6 @@
1
- class Create<%= plural_class_name %> < ActiveRecord::Migration
1
+ class Create<%= class_name.pluralize.delete('::') %> < ActiveRecord::Migration
2
2
  def self.up
3
- create_table :<%= plural_name %> do |t|
3
+ create_table :<%= table_name || plural_name.split('/').last %> do |t|
4
4
  <%- for attribute in model_attributes -%>
5
5
  t.<%= attribute.type %> :<%= attribute.name %>
6
6
  <%- end -%>
@@ -11,6 +11,6 @@ class Create<%= plural_class_name %> < ActiveRecord::Migration
11
11
  end
12
12
 
13
13
  def self.down
14
- drop_table :<%= plural_name %>
14
+ drop_table :<%= table_name || plural_name.split('/').last %>
15
15
  end
16
16
  end
@@ -1,3 +1,4 @@
1
1
  class <%= class_name %> < ActiveRecord::Base
2
+ <%= "set_table_name :#{table_name}\n" if table_name -%>
2
3
  attr_accessible <%= model_attributes.map { |a| ":#{a.name}" }.join(", ") %>
3
4
  end
@@ -1,6 +1,6 @@
1
1
  it "destroy action should destroy model and redirect to index action" do
2
- <%= singular_name %> = <%= class_name %>.first
3
- delete :destroy, :id => <%= singular_name %>
4
- response.should redirect_to(<%= items_path('url') %>)
5
- <%= class_name %>.exists?(<%= singular_name %>.id).should be_false
2
+ <%= instance_name %> = <%= class_name %>.first
3
+ delete :destroy, :id => <%= instance_name %>
4
+ response.should redirect_to(<%= items_url %>)
5
+ <%= class_name %>.exists?(<%= instance_name %>.id).should be_false
6
6
  end
@@ -1,8 +1,8 @@
1
1
  context "destroy action" do
2
2
  should "destroy model and redirect to index action" do
3
- <%= singular_name %> = <%= class_name %>.first
4
- delete :destroy, :id => <%= singular_name %>
5
- assert_redirected_to <%= items_path('url') %>
6
- assert !<%= class_name %>.exists?(<%= singular_name %>.id)
3
+ <%= instance_name %> = <%= class_name %>.first
4
+ delete :destroy, :id => <%= instance_name %>
5
+ assert_redirected_to <%= items_url %>
6
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
7
7
  end
8
8
  end
@@ -1,6 +1,6 @@
1
1
  def test_destroy
2
- <%= singular_name %> = <%= class_name %>.first
3
- delete :destroy, :id => <%= singular_name %>
4
- assert_redirected_to <%= items_path('url') %>
5
- assert !<%= class_name %>.exists?(<%= singular_name %>.id)
2
+ <%= instance_name %> = <%= class_name %>.first
3
+ delete :destroy, :id => <%= instance_name %>
4
+ assert_redirected_to <%= items_url %>
5
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
6
6
  end
@@ -1,4 +1,4 @@
1
- <%%= form_for @<%= singular_name %> do |f| %>
1
+ <%%= form_for <%= item_path :instance_variable => true %> do |f| %>
2
2
  <%%= f.error_messages %>
3
3
  <%- for attribute in model_attributes -%>
4
4
  <p>
@@ -5,10 +5,10 @@
5
5
  <%- if actions? :show, :index -%>
6
6
  <p>
7
7
  <%- if action? :show -%>
8
- <%%= link_to "Show", @<%= singular_name %> %> |
8
+ <%%= link_to "Show", <%= item_path :instance_variable => true %> %> |
9
9
  <%- end -%>
10
10
  <%- if action? :index -%>
11
- <%%= link_to "View All", <%= plural_name %>_path %>
11
+ <%%= link_to "View All", <%= items_path %> %>
12
12
  <%- end -%>
13
13
  </p>
14
14
  <%- end -%>
@@ -6,24 +6,24 @@
6
6
  <th><%= attribute.human_name.titleize %></th>
7
7
  <%- end -%>
8
8
  </tr>
9
- <%% for <%= singular_name %> in @<%= plural_name %> %>
9
+ <%% for <%= instance_name %> in @<%= instances_name %> %>
10
10
  <tr>
11
11
  <%- for attribute in model_attributes -%>
12
- <td><%%= <%= singular_name %>.<%= attribute.name %> %></td>
12
+ <td><%%= <%= instance_name %>.<%= attribute.name %> %></td>
13
13
  <%- end -%>
14
14
  <%- if action? :show -%>
15
- <td><%%= link_to "Show", <%= singular_name %> %></td>
15
+ <td><%%= link_to "Show", <%= item_path %> %></td>
16
16
  <%- end -%>
17
17
  <%- if action? :edit -%>
18
- <td><%%= link_to "Edit", edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
18
+ <td><%%= link_to "Edit", <%= item_path :action => :edit %> %></td>
19
19
  <%- end -%>
20
20
  <%- if action? :destroy -%>
21
- <td><%%= link_to "Destroy", <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
21
+ <td><%%= link_to "Destroy", <%= item_path %>, :confirm => 'Are you sure?', :method => :delete %></td>
22
22
  <%- end -%>
23
23
  </tr>
24
24
  <%% end %>
25
25
  </table>
26
26
 
27
27
  <%- if action? :new -%>
28
- <p><%%= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path %></p>
28
+ <p><%%= link_to "New <%= singular_name.titleize %>", <%= item_path :action => :new %> %></p>
29
29
  <%- end -%>
@@ -3,5 +3,5 @@
3
3
  <%= render_form %>
4
4
 
5
5
  <%- if action? :index -%>
6
- <p><%%= link_to "Back to List", <%= plural_name %>_path %></p>
6
+ <p><%%= link_to "Back to List", <%= items_path %> %></p>
7
7
  <%- end -%>
@@ -3,18 +3,18 @@
3
3
  <%- for attribute in model_attributes -%>
4
4
  <p>
5
5
  <strong><%= attribute.human_name.titleize %>:</strong>
6
- <%%= @<%= singular_name %>.<%= attribute.name %> %>
6
+ <%%= @<%= instance_name %>.<%= attribute.name %> %>
7
7
  </p>
8
8
  <%- end -%>
9
9
 
10
10
  <p>
11
11
  <%- if action? :edit -%>
12
- <%%= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
12
+ <%%= link_to "Edit", <%= item_path :action => :edit, :instance_variable => true %> %> |
13
13
  <%- end -%>
14
14
  <%- if action? :destroy -%>
15
- <%%= link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %> |
15
+ <%%= link_to "Destroy", <%= item_path :instance_variable => true %>, :confirm => 'Are you sure?', :method => :delete %> |
16
16
  <%- end -%>
17
17
  <%- if action? :index -%>
18
- <%%= link_to "View All", <%= plural_name %>_path %>
18
+ <%%= link_to "View All", <%= items_path %> %>
19
19
  <%- end -%>
20
20
  </p>
@@ -1,4 +1,4 @@
1
- = form_for @<%= singular_name %> do |f|
1
+ = form_for <%= item_path %> do |f|
2
2
  = f.error_messages
3
3
  <%- for attribute in model_attributes -%>
4
4
  %p
@@ -5,10 +5,10 @@
5
5
  <%- if actions? :show, :index -%>
6
6
  %p
7
7
  <%- if action? :show -%>
8
- = link_to "Show", <%= singular_name %>_path(@<%= singular_name %>)
8
+ = link_to "Show", <%= item_path %>
9
9
  |
10
10
  <%- end -%>
11
11
  <%- if action? :index -%>
12
- = link_to "View All", <%= plural_name %>_path
12
+ = link_to "View All", <%= items_path %>
13
13
  <%- end -%>
14
14
  <%- end -%>
@@ -5,21 +5,21 @@
5
5
  <%- for attribute in model_attributes -%>
6
6
  %th <%= attribute.human_name %>
7
7
  <%- end -%>
8
- - for <%= singular_name %> in @<%= plural_name %>
8
+ - for <%= instance_name %> in @<%= instances_name %>
9
9
  %tr
10
10
  <%- for attribute in model_attributes -%>
11
- %td= <%= singular_name %>.<%= attribute.name %>
11
+ %td= <%= instance_name %>.<%= attribute.name %>
12
12
  <%- end -%>
13
13
  <%- if action? :show -%>
14
- %td= link_to 'Show', <%= singular_name %>
14
+ %td= link_to 'Show', <%= item_path %>
15
15
  <%- end -%>
16
16
  <%- if action? :edit -%>
17
- %td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
17
+ %td= link_to 'Edit', <%= item_path :action => :edit %>
18
18
  <%- end -%>
19
19
  <%- if action? :destroy -%>
20
- %td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
20
+ %td= link_to 'Destroy', <%= item_path %>, :confirm => 'Are you sure?', :method => :delete
21
21
  <%- end -%>
22
22
 
23
23
  <%- if actions? :new -%>
24
- %p= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path
24
+ %p= link_to "New <%= singular_name.titleize %>", <%= item_path :action => :new %>
25
25
  <%- end -%>
@@ -3,5 +3,5 @@
3
3
  <%= render_form %>
4
4
 
5
5
  <%- if action? :index -%>
6
- %p= link_to "Back to List", <%= plural_name %>_path
6
+ %p= link_to "Back to List", <%= items_path %>
7
7
  <%- end -%>
@@ -3,18 +3,18 @@
3
3
  <%- for attribute in model_attributes -%>
4
4
  %p
5
5
  %strong <%= attribute.human_name.titleize %>:
6
- = @<%= singular_name %>.<%= attribute.name %>
6
+ = @<%= instance_name %>.<%= attribute.name %>
7
7
  <%- end -%>
8
8
 
9
9
  %p
10
10
  <%- if action? :edit -%>
11
- = link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>)
11
+ = link_to "Edit", <%= item_path :action => :edit, :instance_variable => true %>
12
12
  |
13
13
  <%- end -%>
14
14
  <%- if action? :destroy -%>
15
- = link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
15
+ = link_to "Destroy", <%= item_path :instance_variable => true %>, :confirm => 'Are you sure?', :method => :delete
16
16
  |
17
17
  <%- end -%>
18
18
  <%- if action? :index -%>
19
- = link_to "View All", <%= plural_name %>_path
19
+ = link_to "View All", <%= items_path %>
20
20
  <%- end -%>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 3
9
- version: 0.4.3
8
+ - 4
9
+ version: 0.4.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Bates
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-28 00:00:00 -08:00
17
+ date: 2011-01-17 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency