railties 3.0.20 → 3.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/CHANGELOG +36 -49
  2. data/README.rdoc +2 -1
  3. data/guides/assets/stylesheets/fixes.css +16 -0
  4. data/guides/rails_guides.rb +2 -2
  5. data/guides/rails_guides/generator.rb +8 -3
  6. data/guides/rails_guides/textile_extensions.rb +4 -2
  7. data/guides/source/2_2_release_notes.textile +3 -3
  8. data/guides/source/2_3_release_notes.textile +2 -2
  9. data/guides/source/3_0_release_notes.textile +14 -14
  10. data/guides/source/action_controller_overview.textile +54 -79
  11. data/guides/source/action_mailer_basics.textile +39 -9
  12. data/guides/source/action_view_overview.textile +257 -211
  13. data/guides/source/active_record_basics.textile +1 -1
  14. data/guides/source/active_record_querying.textile +217 -27
  15. data/guides/source/active_record_validations_callbacks.textile +94 -25
  16. data/guides/source/active_support_core_extensions.textile +109 -77
  17. data/guides/source/ajax_on_rails.textile +15 -150
  18. data/guides/source/api_documentation_guidelines.textile +12 -12
  19. data/guides/source/association_basics.textile +74 -60
  20. data/guides/source/caching_with_rails.textile +59 -60
  21. data/guides/source/command_line.textile +46 -47
  22. data/guides/source/configuring.textile +55 -37
  23. data/guides/source/contribute.textile +7 -7
  24. data/guides/source/contributing_to_ruby_on_rails.textile +14 -23
  25. data/guides/source/credits.html.erb +3 -3
  26. data/guides/source/debugging_rails_applications.textile +59 -46
  27. data/guides/source/form_helpers.textile +76 -31
  28. data/guides/source/generators.textile +39 -40
  29. data/guides/source/getting_started.textile +73 -94
  30. data/guides/source/i18n.textile +64 -58
  31. data/guides/source/index.html.erb +3 -3
  32. data/guides/source/initialization.textile +634 -3284
  33. data/guides/source/layout.html.erb +6 -7
  34. data/guides/source/layouts_and_rendering.textile +59 -60
  35. data/guides/source/migrations.textile +63 -59
  36. data/guides/source/nested_model_forms.textile +2 -2
  37. data/guides/source/performance_testing.textile +16 -16
  38. data/guides/source/plugins.textile +236 -1280
  39. data/guides/source/rails_application_templates.textile +37 -29
  40. data/guides/source/rails_on_rack.textile +4 -9
  41. data/guides/source/routing.textile +96 -75
  42. data/guides/source/ruby_on_rails_guides_guidelines.textile +19 -12
  43. data/guides/source/security.textile +57 -30
  44. data/guides/source/testing.textile +26 -24
  45. data/guides/w3c_validator.rb +2 -2
  46. data/lib/rails.rb +1 -7
  47. data/lib/rails/application.rb +46 -76
  48. data/lib/rails/application/bootstrap.rb +6 -11
  49. data/lib/rails/application/configuration.rb +43 -40
  50. data/lib/rails/application/finisher.rb +16 -4
  51. data/lib/rails/application/railties.rb +6 -24
  52. data/lib/rails/application/routes_reloader.rb +45 -0
  53. data/lib/rails/backtrace_cleaner.rb +1 -1
  54. data/lib/rails/cli.rb +7 -5
  55. data/lib/rails/commands.rb +27 -2
  56. data/lib/rails/commands/application.rb +14 -1
  57. data/lib/rails/commands/benchmarker.rb +3 -1
  58. data/lib/rails/commands/dbconsole.rb +2 -2
  59. data/lib/rails/commands/destroy.rb +3 -1
  60. data/lib/rails/commands/generate.rb +3 -1
  61. data/lib/rails/commands/plugin.rb +2 -7
  62. data/lib/rails/commands/plugin_new.rb +10 -0
  63. data/lib/rails/commands/profiler.rb +3 -1
  64. data/lib/rails/commands/server.rb +4 -0
  65. data/lib/rails/configuration.rb +8 -81
  66. data/lib/rails/console/app.rb +2 -2
  67. data/lib/rails/engine.rb +460 -78
  68. data/lib/rails/engine/configuration.rb +46 -49
  69. data/lib/rails/engine/railties.rb +33 -0
  70. data/lib/rails/generators.rb +11 -5
  71. data/lib/rails/generators/actions.rb +2 -27
  72. data/lib/rails/generators/app_base.rb +216 -0
  73. data/lib/rails/generators/base.rb +3 -2
  74. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -1
  75. data/lib/rails/generators/generated_attribute.rb +2 -1
  76. data/lib/rails/generators/migration.rb +6 -2
  77. data/lib/rails/generators/named_base.rb +79 -3
  78. data/lib/rails/generators/rails/app/app_generator.rb +44 -209
  79. data/lib/rails/generators/rails/app/templates/Gemfile +15 -31
  80. data/lib/rails/generators/rails/app/templates/README +2 -2
  81. data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
  82. data/lib/rails/generators/rails/app/templates/{public → app/assets}/images/rails.png +0 -0
  83. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +8 -0
  84. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -0
  85. data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
  86. data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
  87. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
  88. data/lib/rails/generators/rails/app/templates/config/application.rb +19 -3
  89. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +4 -4
  90. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +11 -6
  91. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
  92. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
  93. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -2
  94. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -11
  95. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -1
  96. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
  97. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +12 -0
  98. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
  99. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  100. data/lib/rails/generators/rails/app/templates/db/{seeds.rb → seeds.rb.tt} +2 -2
  101. data/lib/rails/generators/rails/app/templates/public/index.html +10 -8
  102. data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  103. data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  104. data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  105. data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  106. data/lib/rails/generators/rails/app/templates/test/{test_helper.rb.tt → test_helper.rb} +0 -0
  107. data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  108. data/lib/rails/generators/rails/assets/USAGE +20 -0
  109. data/lib/rails/generators/rails/assets/assets_generator.rb +39 -0
  110. data/lib/rails/generators/rails/assets/templates/javascript.js +2 -0
  111. data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +3 -0
  112. data/lib/rails/generators/rails/assets/templates/stylesheet.css +4 -0
  113. data/lib/rails/generators/rails/assets/templates/stylesheet.css.scss +5 -0
  114. data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
  115. data/lib/rails/generators/rails/controller/templates/controller.rb +2 -0
  116. data/lib/rails/generators/rails/generator/generator_generator.rb +2 -2
  117. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  118. data/lib/rails/generators/rails/helper/templates/helper.rb +2 -0
  119. data/lib/rails/generators/rails/plugin/plugin_generator.rb +7 -0
  120. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -4
  121. data/lib/rails/generators/rails/plugin_new/USAGE +10 -0
  122. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +303 -0
  123. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +9 -0
  124. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +11 -0
  125. data/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE +20 -0
  126. data/lib/rails/generators/rails/plugin_new/templates/README.rdoc +3 -0
  127. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +21 -0
  128. data/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +4 -0
  129. data/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt +4 -0
  130. data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
  131. data/lib/rails/generators/rails/plugin_new/templates/config/routes.rb +6 -0
  132. data/lib/rails/generators/rails/plugin_new/templates/gitignore +6 -0
  133. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb +6 -0
  134. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +7 -0
  135. data/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake +4 -0
  136. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +16 -0
  137. data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +10 -0
  138. data/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb +4 -0
  139. data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -0
  140. data/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb +7 -0
  141. data/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +12 -0
  142. data/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +10 -0
  143. data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
  144. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +20 -1
  145. data/lib/rails/generators/rails/{stylesheets → scaffold}/templates/scaffold.css +0 -0
  146. data/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +58 -0
  147. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +21 -19
  148. data/lib/rails/generators/resource_helpers.rb +3 -3
  149. data/lib/rails/generators/test_case.rb +2 -20
  150. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +5 -4
  151. data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +2 -0
  152. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +3 -4
  153. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +5 -4
  154. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +1 -1
  155. data/lib/rails/generators/test_unit/model/templates/unit_test.rb +5 -4
  156. data/lib/rails/generators/test_unit/observer/templates/unit_test.rb +5 -4
  157. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +3 -4
  158. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +7 -5
  159. data/lib/rails/info.rb +0 -1
  160. data/lib/rails/paths.rb +119 -65
  161. data/lib/rails/plugin.rb +18 -19
  162. data/lib/rails/rack/log_tailer.rb +1 -1
  163. data/lib/rails/railtie.rb +50 -47
  164. data/lib/rails/railtie/configurable.rb +20 -10
  165. data/lib/rails/railtie/configuration.rb +20 -19
  166. data/lib/rails/source_annotation_extractor.rb +5 -5
  167. data/lib/rails/tasks.rb +1 -0
  168. data/lib/rails/tasks/assets.rake +10 -0
  169. data/lib/rails/tasks/documentation.rake +2 -8
  170. data/lib/rails/tasks/engine.rake +69 -0
  171. data/lib/rails/tasks/framework.rake +4 -21
  172. data/lib/rails/tasks/misc.rake +1 -1
  173. data/lib/rails/tasks/routes.rake +2 -1
  174. data/lib/rails/test_help.rb +17 -1
  175. data/lib/rails/test_unit/railtie.rb +1 -1
  176. data/lib/rails/test_unit/testing.rake +8 -3
  177. data/lib/rails/version.rb +3 -3
  178. metadata +128 -100
  179. checksums.yaml +0 -7
  180. data/lib/rails/application/configurable.rb +0 -19
  181. data/lib/rails/console/sandbox.rb +0 -6
  182. data/lib/rails/deprecation.rb +0 -41
  183. data/lib/rails/engine/configurable.rb +0 -25
  184. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +0 -62
  185. data/lib/rails/generators/rails/app/templates/public/javascripts/application.js +0 -2
  186. data/lib/rails/generators/rails/app/templates/public/javascripts/controls.js +0 -965
  187. data/lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js +0 -974
  188. data/lib/rails/generators/rails/app/templates/public/javascripts/effects.js +0 -1123
  189. data/lib/rails/generators/rails/app/templates/public/javascripts/prototype.js +0 -6001
  190. data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +0 -202
  191. data/lib/rails/generators/rails/stylesheets/USAGE +0 -5
  192. data/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb +0 -9
  193. data/lib/rails/info_routes.rb +0 -3
@@ -0,0 +1,9 @@
1
+ # Provide a simple gemspec so you can easily use your
2
+ # project in your rails apps through git.
3
+ Gem::Specification.new do |s|
4
+ s.name = "<%= name %>"
5
+ s.summary = "Insert <%= camelized %> summary."
6
+ s.description = "Insert <%= camelized %> description."
7
+ s.files = Dir["lib/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
8
+ s.version = "0.0.1"
9
+ end
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ <%= rails_gemfile_entry -%>
4
+
5
+ <% if full? -%>
6
+ <%= database_gemfile_entry -%>
7
+ <% end -%>
8
+
9
+ if RUBY_VERSION < '1.9'
10
+ gem "ruby-debug", ">= 0.10.3"
11
+ end
@@ -0,0 +1,20 @@
1
+ Copyright <%= Date.today.year %> YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = <%= camelized %>
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ require 'rake/rdoctask'
9
+
10
+ Rake::RDocTask.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = '<%= camelized %>'
13
+ rdoc.options << '--line-numbers' << '--inline-source'
14
+ rdoc.rdoc_files.include('README.rdoc')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ <% if full? && !options[:skip_active_record] -%>
19
+ APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
20
+ load 'rails/tasks/engine.rake'
21
+ <% end %>
@@ -0,0 +1,4 @@
1
+ module <%= camelized %>
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module <%= camelized %>
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ <% if mountable? -%>
2
+ <%= camelized %>::Engine.routes.draw do
3
+ <% else -%>
4
+ Rails.application.routes.draw do
5
+ <% end -%>
6
+ end
@@ -0,0 +1,6 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/log/*.log
6
+ test/dummy/tmp/
@@ -0,0 +1,6 @@
1
+ <% if full? -%>
2
+ require "<%= name %>/engine"
3
+
4
+ <% end -%>
5
+ module <%= camelized %>
6
+ end
@@ -0,0 +1,7 @@
1
+ module <%= camelized %>
2
+ class Engine < Rails::Engine
3
+ <% if mountable? -%>
4
+ isolate_namespace <%= camelized %>
5
+ <% end -%>
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :<%= name %> do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ <% unless options[:skip_active_record] -%>
4
+ require 'rails/all'
5
+ <% else -%>
6
+ # require "active_record/railtie"
7
+ require "action_controller/railtie"
8
+ require "action_mailer/railtie"
9
+ require "active_resource/railtie"
10
+ require "rails/test_unit/railtie"
11
+ <% end -%>
12
+
13
+ Bundler.require
14
+ require "<%= name %>"
15
+
16
+ <%= application_definition %>
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+
3
+ mount <%= camelized %>::Engine => "/<%= name %>"
4
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
5
+ load File.expand_path('../../<%= dummy_path %>/script/rails', __FILE__)
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= camelized %>Test < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, <%= camelized %>
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ <% unless options[:skip_active_record] -%>
5
+ fixtures :all
6
+ <% end -%>
7
+
8
+ # test "the truth" do
9
+ # assert true
10
+ # end
11
+ end
12
+
@@ -0,0 +1,10 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@@ -16,9 +16,9 @@ module Rails
16
16
 
17
17
  def add_resource_route
18
18
  return if options[:actions].present?
19
- route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
19
+ route_config = regular_class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
20
20
  route_config << "resources :#{file_name.pluralize}"
21
- route_config << " end" * class_path.size
21
+ route_config << " end" * regular_class_path.size
22
22
  route route_config
23
23
  end
24
24
  end
@@ -6,8 +6,27 @@ module Rails
6
6
  remove_hook_for :resource_controller
7
7
  remove_class_option :actions
8
8
 
9
+ class_option :stylesheets, :type => :boolean, :desc => "Generate stylesheets"
10
+ class_option :stylesheet_engine, :desc => "Engine for stylesheets"
11
+
9
12
  hook_for :scaffold_controller, :required => true
10
- hook_for :stylesheets
13
+
14
+ def copy_stylesheets_file
15
+ if behavior == :invoke && options.stylesheets?
16
+ template "scaffold.#{stylesheet_extension}", "app/assets/stylesheets/scaffold.#{stylesheet_extension}"
17
+ end
18
+ end
19
+
20
+ hook_for :assets do |assets|
21
+ invoke assets, [controller_name]
22
+ end
23
+
24
+ private
25
+
26
+ def stylesheet_extension
27
+ options.stylesheet_engine.present? ?
28
+ "css.#{options.stylesheet_engine}" : "css"
29
+ end
11
30
  end
12
31
  end
13
32
  end
@@ -0,0 +1,58 @@
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 {
16
+ color: #000;
17
+ &:visited { color: #666; }
18
+ &:hover { color: #fff; background-color:#000; }
19
+ }
20
+
21
+ div.field, div.actions {
22
+ margin-bottom: 10px;
23
+ }
24
+
25
+ #notice {
26
+ color: green;
27
+ }
28
+
29
+ .field_with_errors {
30
+ padding: 2px;
31
+ background-color: red;
32
+ display: table;
33
+ }
34
+
35
+ #error_explanation {
36
+ width: 450px;
37
+ border: 2px solid red;
38
+ padding: 7px;
39
+ padding-bottom: 0;
40
+ margin-bottom: 20px;
41
+ background-color: #f0f0f0;
42
+
43
+ h2 {
44
+ text-align: left;
45
+ font-weight: bold;
46
+ padding: 5px 5px 5px 15px;
47
+ font-size: 12px;
48
+ margin: -7px;
49
+ margin-bottom: 0px;
50
+ background-color: #c00;
51
+ color: #fff;
52
+ }
53
+
54
+ ul li {
55
+ font-size: 12px;
56
+ list-style: square;
57
+ }
58
+ }
@@ -1,34 +1,35 @@
1
+ <% module_namespacing do -%>
1
2
  class <%= controller_class_name %>Controller < ApplicationController
2
3
  # GET <%= route_url %>
3
- # GET <%= route_url %>.xml
4
+ # GET <%= route_url %>.json
4
5
  def index
5
6
  @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
6
7
 
7
8
  respond_to do |format|
8
9
  format.html # index.html.erb
9
- format.xml { render :xml => @<%= plural_table_name %> }
10
+ format.json { render <%= key_value :json, "@#{plural_table_name}" %> }
10
11
  end
11
12
  end
12
13
 
13
14
  # GET <%= route_url %>/1
14
- # GET <%= route_url %>/1.xml
15
+ # GET <%= route_url %>/1.json
15
16
  def show
16
17
  @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
17
18
 
18
19
  respond_to do |format|
19
20
  format.html # show.html.erb
20
- format.xml { render :xml => @<%= singular_table_name %> }
21
+ format.json { render <%= key_value :json, "@#{singular_table_name}" %> }
21
22
  end
22
23
  end
23
24
 
24
25
  # GET <%= route_url %>/new
25
- # GET <%= route_url %>/new.xml
26
+ # GET <%= route_url %>/new.json
26
27
  def new
27
28
  @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
28
29
 
29
30
  respond_to do |format|
30
31
  format.html # new.html.erb
31
- format.xml { render :xml => @<%= singular_table_name %> }
32
+ format.json { render <%= key_value :json, "@#{singular_table_name}" %> }
32
33
  end
33
34
  end
34
35
 
@@ -38,46 +39,47 @@ class <%= controller_class_name %>Controller < ApplicationController
38
39
  end
39
40
 
40
41
  # POST <%= route_url %>
41
- # POST <%= route_url %>.xml
42
+ # POST <%= route_url %>.json
42
43
  def create
43
44
  @<%= singular_table_name %> = <%= orm_class.build(class_name, "params[:#{singular_table_name}]") %>
44
45
 
45
46
  respond_to do |format|
46
47
  if @<%= orm_instance.save %>
47
- format.html { redirect_to(@<%= singular_table_name %>, :notice => '<%= human_name %> was successfully created.') }
48
- format.xml { render :xml => @<%= singular_table_name %>, :status => :created, :location => @<%= singular_table_name %> }
48
+ format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
49
+ format.json { render <%= key_value :json, "@#{singular_table_name}" %>, <%= key_value :status, ':created' %>, <%= key_value :location, "@#{singular_table_name}" %> }
49
50
  else
50
- format.html { render :action => "new" }
51
- format.xml { render :xml => @<%= orm_instance.errors %>, :status => :unprocessable_entity }
51
+ format.html { render <%= key_value :action, '"new"' %> }
52
+ format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
52
53
  end
53
54
  end
54
55
  end
55
56
 
56
57
  # PUT <%= route_url %>/1
57
- # PUT <%= route_url %>/1.xml
58
+ # PUT <%= route_url %>/1.json
58
59
  def update
59
60
  @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
60
61
 
61
62
  respond_to do |format|
62
63
  if @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %>
63
- format.html { redirect_to(@<%= singular_table_name %>, :notice => '<%= human_name %> was successfully updated.') }
64
- format.xml { head :ok }
64
+ format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
65
+ format.json { head :ok }
65
66
  else
66
- format.html { render :action => "edit" }
67
- format.xml { render :xml => @<%= orm_instance.errors %>, :status => :unprocessable_entity }
67
+ format.html { render <%= key_value :action, '"edit"' %> }
68
+ format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
68
69
  end
69
70
  end
70
71
  end
71
72
 
72
73
  # DELETE <%= route_url %>/1
73
- # DELETE <%= route_url %>/1.xml
74
+ # DELETE <%= route_url %>/1.json
74
75
  def destroy
75
76
  @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
76
77
  @<%= orm_instance.destroy %>
77
78
 
78
79
  respond_to do |format|
79
- format.html { redirect_to(<%= index_helper %>_url) }
80
- format.xml { head :ok }
80
+ format.html { redirect_to <%= index_helper %>_url }
81
+ format.json { head :ok }
81
82
  end
82
83
  end
83
84
  end
85
+ <% end -%>
@@ -34,7 +34,7 @@ module Rails
34
34
  attr_reader :controller_name
35
35
 
36
36
  def controller_class_path
37
- @class_path
37
+ class_path
38
38
  end
39
39
 
40
40
  def controller_file_name
@@ -46,14 +46,14 @@ module Rails
46
46
  end
47
47
 
48
48
  def controller_class_name
49
- @controller_class_name ||= (controller_class_path + [controller_file_name]).map!{ |m| m.camelize }.join('::')
49
+ (controller_class_path + [controller_file_name]).map!{ |m| m.camelize }.join('::')
50
50
  end
51
51
 
52
52
  def controller_i18n_scope
53
53
  @controller_i18n_scope ||= controller_file_path.gsub('/', '.')
54
54
  end
55
55
 
56
- # Loads the ORM::Generators::ActiveModel class. This class is responsable
56
+ # Loads the ORM::Generators::ActiveModel class. This class is responsible
57
57
  # to tell scaffold entities how to generate an specific method for the
58
58
  # ORM. Check Rails::Generators::ActiveModel for more information.
59
59
  def orm_class
@@ -1,6 +1,7 @@
1
1
  require 'active_support/core_ext/class/attribute'
2
2
  require 'active_support/core_ext/module/delegation'
3
3
  require 'active_support/core_ext/hash/reverse_merge'
4
+ require 'active_support/core_ext/kernel/reporting'
4
5
  require 'rails/generators'
5
6
  require 'fileutils'
6
7
 
@@ -65,25 +66,6 @@ module Rails
65
66
  self.destination_root = path
66
67
  end
67
68
 
68
- # Captures the given stream and returns it:
69
- #
70
- # stream = capture(:stdout){ puts "Cool" }
71
- # stream # => "Cool\n"
72
- #
73
- def capture(stream)
74
- begin
75
- stream = stream.to_s
76
- eval "$#{stream} = StringIO.new"
77
- yield
78
- result = eval("$#{stream}").string
79
- ensure
80
- eval("$#{stream} = #{stream.upcase}")
81
- end
82
-
83
- result
84
- end
85
- alias :silence :capture
86
-
87
69
  # Asserts a given file exists. You need to supply an absolute path or a path relative
88
70
  # to the configured destination:
89
71
  #
@@ -132,7 +114,7 @@ module Rails
132
114
  end
133
115
  alias :assert_no_directory :assert_no_file
134
116
 
135
- # Asserts a given file does not exist. You need to supply an absolute path or a
117
+ # Asserts a given migration exists. You need to supply an absolute path or a
136
118
  # path relative to the configured destination:
137
119
  #
138
120
  # assert_migration "db/migrate/create_products.rb"