railties 3.1.12 → 3.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/CHANGELOG.md +2292 -41
  2. data/README.rdoc +14 -5
  3. data/bin/rails +7 -0
  4. data/guides/code/getting_started/Gemfile +27 -0
  5. data/guides/code/getting_started/README.rdoc +261 -0
  6. data/guides/code/getting_started/Rakefile +7 -0
  7. data/guides/code/getting_started/app/assets/images/rails.png +0 -0
  8. data/guides/code/getting_started/app/assets/javascripts/application.js +9 -0
  9. data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +3 -0
  10. data/guides/code/getting_started/app/assets/javascripts/home.js.coffee +3 -0
  11. data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +3 -0
  12. data/guides/code/getting_started/app/assets/stylesheets/application.css +7 -0
  13. data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +3 -0
  14. data/guides/code/getting_started/app/assets/stylesheets/home.css.scss +3 -0
  15. data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +3 -0
  16. data/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss +56 -0
  17. data/guides/code/getting_started/app/controllers/application_controller.rb +3 -0
  18. data/guides/code/getting_started/app/controllers/comments_controller.rb +16 -0
  19. data/guides/code/getting_started/app/controllers/home_controller.rb +5 -0
  20. data/guides/code/getting_started/app/controllers/posts_controller.rb +84 -0
  21. data/guides/code/getting_started/app/helpers/application_helper.rb +2 -0
  22. data/guides/code/getting_started/app/helpers/comments_helper.rb +2 -0
  23. data/guides/code/getting_started/app/helpers/home_helper.rb +2 -0
  24. data/guides/code/getting_started/app/helpers/posts_helper.rb +5 -0
  25. data/guides/code/getting_started/app/models/comment.rb +3 -0
  26. data/guides/code/getting_started/app/models/post.rb +11 -0
  27. data/guides/code/getting_started/app/models/tag.rb +3 -0
  28. data/guides/code/getting_started/app/views/comments/_comment.html.erb +15 -0
  29. data/guides/code/getting_started/app/views/comments/_form.html.erb +13 -0
  30. data/guides/code/getting_started/app/views/home/index.html.erb +2 -0
  31. data/guides/code/getting_started/app/views/layouts/application.html.erb +14 -0
  32. data/guides/code/getting_started/app/views/posts/_form.html.erb +32 -0
  33. data/guides/code/getting_started/app/views/posts/edit.html.erb +6 -0
  34. data/guides/code/getting_started/app/views/posts/index.html.erb +27 -0
  35. data/guides/code/getting_started/app/views/posts/new.html.erb +5 -0
  36. data/guides/code/getting_started/app/views/posts/show.html.erb +31 -0
  37. data/guides/code/getting_started/app/views/tags/_form.html.erb +12 -0
  38. data/guides/code/getting_started/config.ru +4 -0
  39. data/guides/code/getting_started/config/application.rb +53 -0
  40. data/guides/code/getting_started/config/boot.rb +6 -0
  41. data/guides/code/getting_started/config/database.yml +25 -0
  42. data/guides/code/getting_started/config/environment.rb +5 -0
  43. data/guides/code/getting_started/config/environments/development.rb +37 -0
  44. data/guides/code/getting_started/config/environments/production.rb +67 -0
  45. data/guides/code/getting_started/config/environments/test.rb +37 -0
  46. data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +7 -0
  47. data/guides/code/getting_started/config/initializers/inflections.rb +10 -0
  48. data/guides/code/getting_started/config/initializers/mime_types.rb +5 -0
  49. data/guides/code/getting_started/config/initializers/secret_token.rb +7 -0
  50. data/guides/code/getting_started/config/initializers/session_store.rb +8 -0
  51. data/guides/code/getting_started/config/initializers/wrap_parameters.rb +14 -0
  52. data/guides/code/getting_started/config/locales/en.yml +5 -0
  53. data/guides/code/getting_started/config/routes.rb +64 -0
  54. data/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb +11 -0
  55. data/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb +12 -0
  56. data/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb +11 -0
  57. data/guides/code/getting_started/db/schema.rb +43 -0
  58. data/guides/code/getting_started/db/seeds.rb +7 -0
  59. data/guides/code/getting_started/doc/README_FOR_APP +2 -0
  60. data/guides/code/getting_started/public/404.html +26 -0
  61. data/guides/code/getting_started/public/422.html +26 -0
  62. data/guides/code/getting_started/public/500.html +26 -0
  63. data/guides/code/getting_started/public/favicon.ico +0 -0
  64. data/guides/code/getting_started/public/robots.txt +5 -0
  65. data/guides/code/getting_started/script/rails +6 -0
  66. data/guides/code/getting_started/test/fixtures/comments.yml +11 -0
  67. data/guides/code/getting_started/test/fixtures/posts.yml +11 -0
  68. data/guides/code/getting_started/test/fixtures/tags.yml +9 -0
  69. data/guides/code/getting_started/test/functional/comments_controller_test.rb +7 -0
  70. data/guides/code/getting_started/test/functional/home_controller_test.rb +9 -0
  71. data/guides/code/getting_started/test/functional/posts_controller_test.rb +49 -0
  72. data/guides/code/getting_started/test/performance/browsing_test.rb +12 -0
  73. data/guides/code/getting_started/test/test_helper.rb +13 -0
  74. data/guides/code/getting_started/test/unit/comment_test.rb +7 -0
  75. data/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb +4 -0
  76. data/guides/code/getting_started/test/unit/helpers/home_helper_test.rb +4 -0
  77. data/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb +4 -0
  78. data/guides/code/getting_started/test/unit/post_test.rb +7 -0
  79. data/guides/code/getting_started/test/unit/tag_test.rb +7 -0
  80. data/guides/rails_guides/generator.rb +2 -1
  81. data/guides/source/3_0_release_notes.textile +2 -2
  82. data/guides/source/3_1_release_notes.textile +3 -110
  83. data/guides/source/action_controller_overview.textile +11 -13
  84. data/guides/source/action_mailer_basics.textile +7 -18
  85. data/guides/source/action_view_overview.textile +78 -9
  86. data/guides/source/active_model_basics.textile +205 -0
  87. data/guides/source/active_record_basics.textile +31 -31
  88. data/guides/source/active_record_querying.textile +288 -67
  89. data/guides/source/active_record_validations_callbacks.textile +69 -75
  90. data/guides/source/active_resource_basics.textile +48 -2
  91. data/guides/source/active_support_core_extensions.textile +145 -24
  92. data/guides/source/ajax_on_rails.textile +65 -7
  93. data/guides/source/api_documentation_guidelines.textile +0 -6
  94. data/guides/source/asset_pipeline.textile +2 -2
  95. data/guides/source/association_basics.textile +25 -34
  96. data/guides/source/caching_with_rails.textile +12 -17
  97. data/guides/source/command_line.textile +29 -19
  98. data/guides/source/configuring.textile +40 -18
  99. data/guides/source/contributing_to_ruby_on_rails.textile +11 -18
  100. data/guides/source/debugging_rails_applications.textile +10 -21
  101. data/guides/source/engines.textile +618 -0
  102. data/guides/source/form_helpers.textile +1 -12
  103. data/guides/source/generators.textile +9 -11
  104. data/guides/source/getting_started.textile +152 -152
  105. data/guides/source/i18n.textile +4 -5
  106. data/guides/source/index.html.erb +0 -1
  107. data/guides/source/initialization.textile +26 -26
  108. data/guides/source/layouts_and_rendering.textile +97 -61
  109. data/guides/source/migrations.textile +380 -161
  110. data/guides/source/performance_testing.textile +4 -10
  111. data/guides/source/plugins.textile +11 -19
  112. data/guides/source/rails_application_templates.textile +12 -4
  113. data/guides/source/rails_on_rack.textile +25 -19
  114. data/guides/source/routing.textile +6 -13
  115. data/guides/source/ruby_on_rails_guides_guidelines.textile +0 -5
  116. data/guides/source/security.textile +11 -15
  117. data/guides/source/testing.textile +1 -9
  118. data/lib/rails/application.rb +107 -42
  119. data/lib/rails/application/bootstrap.rb +12 -11
  120. data/lib/rails/application/configuration.rb +27 -21
  121. data/lib/rails/application/finisher.rb +40 -17
  122. data/lib/rails/application/route_inspector.rb +75 -0
  123. data/lib/rails/application/routes_reloader.rb +15 -4
  124. data/lib/rails/code_statistics.rb +16 -5
  125. data/lib/rails/commands.rb +6 -5
  126. data/lib/rails/commands/application.rb +8 -1
  127. data/lib/rails/commands/console.rb +2 -0
  128. data/lib/rails/commands/dbconsole.rb +2 -2
  129. data/lib/rails/commands/destroy.rb +0 -2
  130. data/lib/rails/commands/generate.rb +3 -3
  131. data/lib/rails/commands/plugin.rb +161 -159
  132. data/lib/rails/commands/plugin_new.rb +3 -2
  133. data/lib/rails/commands/runner.rb +4 -0
  134. data/lib/rails/console/app.rb +26 -22
  135. data/lib/rails/console/helpers.rb +9 -5
  136. data/lib/rails/engine.rb +70 -34
  137. data/lib/rails/engine/commands.rb +39 -0
  138. data/lib/rails/engine/configuration.rb +1 -1
  139. data/lib/rails/generators.rb +3 -14
  140. data/lib/rails/generators/actions.rb +36 -9
  141. data/lib/rails/generators/app_base.rb +34 -38
  142. data/lib/rails/generators/base.rb +4 -4
  143. data/lib/rails/generators/generated_attribute.rb +1 -1
  144. data/lib/rails/generators/named_base.rb +1 -3
  145. data/lib/rails/generators/rails/app/USAGE +6 -0
  146. data/lib/rails/generators/rails/app/app_generator.rb +6 -2
  147. data/lib/rails/generators/rails/app/templates/Gemfile +4 -3
  148. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +9 -3
  149. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +11 -5
  150. data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
  151. data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
  152. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -1
  153. data/lib/rails/generators/rails/app/templates/config/application.rb +11 -0
  154. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +1 -1
  155. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +1 -1
  156. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +10 -1
  157. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +10 -1
  158. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +6 -6
  159. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb +5 -0
  160. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  161. data/lib/rails/generators/rails/app/templates/public/500.html +0 -1
  162. data/lib/rails/generators/rails/app/templates/public/index.html +1 -1
  163. data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  164. data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  165. data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  166. data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  167. data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  168. data/lib/rails/generators/rails/controller/templates/controller.rb +1 -1
  169. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  170. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +17 -5
  171. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +1 -0
  172. data/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory +0 -0
  173. data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
  174. data/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt +1 -1
  175. data/lib/rails/generators/rails/plugin_new/templates/gitignore +4 -3
  176. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +1 -1
  177. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +1 -1
  178. data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -3
  179. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +2 -2
  180. data/lib/rails/generators/rails/task/USAGE +9 -0
  181. data/lib/rails/generators/rails/task/task_generator.rb +12 -0
  182. data/lib/rails/generators/rails/task/templates/task.rb +8 -0
  183. data/lib/rails/generators/resource_helpers.rb +3 -3
  184. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +0 -2
  185. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +4 -4
  186. data/lib/rails/paths.rb +11 -38
  187. data/lib/rails/rack/debugger.rb +3 -4
  188. data/lib/rails/rack/logger.rb +26 -12
  189. data/lib/rails/railtie.rb +6 -1
  190. data/lib/rails/railtie/configuration.rb +12 -5
  191. data/lib/rails/source_annotation_extractor.rb +12 -10
  192. data/lib/rails/tasks/documentation.rake +3 -1
  193. data/lib/rails/tasks/engine.rake +1 -0
  194. data/lib/rails/tasks/misc.rake +1 -1
  195. data/lib/rails/tasks/routes.rake +3 -23
  196. data/lib/rails/test_help.rb +1 -2
  197. data/lib/rails/test_unit/testing.rake +8 -4
  198. data/lib/rails/version.rb +3 -3
  199. metadata +131 -61
  200. checksums.yaml +0 -7
  201. data/lib/rails/generators/rails/plugin/USAGE +0 -13
  202. data/lib/rails/generators/rails/plugin/plugin_generator.rb +0 -54
  203. data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +0 -20
  204. data/lib/rails/generators/rails/plugin/templates/README.tt +0 -13
  205. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +0 -23
  206. data/lib/rails/generators/rails/plugin/templates/init.rb +0 -1
  207. data/lib/rails/generators/rails/plugin/templates/install.rb +0 -1
  208. data/lib/rails/generators/rails/plugin/templates/lib/%file_name%.rb.tt +0 -1
  209. data/lib/rails/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +0 -4
  210. data/lib/rails/generators/rails/plugin/templates/uninstall.rb +0 -1
@@ -34,7 +34,7 @@ module Rails
34
34
  usage = source_root && File.expand_path("../USAGE", source_root)
35
35
 
36
36
  @desc ||= if usage && File.exist?(usage)
37
- File.read(usage)
37
+ ERB.new(File.read(usage)).result(binding)
38
38
  else
39
39
  "Description:\n Create #{base_name.humanize.downcase} files for #{generator_name} generator."
40
40
  end
@@ -259,9 +259,9 @@ module Rails
259
259
  extra << false unless Object.method(:const_defined?).arity == 1
260
260
 
261
261
  # Extract the last Module in the nesting
262
- last = nesting.inject(Object) do |last, nest|
263
- break unless last.const_defined?(nest, *extra)
264
- last.const_get(nest)
262
+ last = nesting.inject(Object) do |last_module, nest|
263
+ break unless last_module.const_defined?(nest, *extra)
264
+ last_module.const_get(nest)
265
265
  end
266
266
 
267
267
  if last && last.const_defined?(last_name.camelize, *extra)
@@ -7,7 +7,7 @@ module Rails
7
7
  attr_accessor :name, :type
8
8
 
9
9
  def initialize(name, type)
10
- raise Thor::Error, "Missing type for attribute '#{name}'.\nExample: '#{name}:string' where string is the type." if type.blank?
10
+ type = :string if type.blank?
11
11
  @name, @type = name, type.to_sym
12
12
  end
13
13
 
@@ -63,9 +63,7 @@ module Rails
63
63
  end
64
64
 
65
65
  def namespace
66
- @namespace ||= if defined?(Rails) && Rails.application
67
- Rails.application.class.parents.detect { |n| n.respond_to?(:_railtie) }
68
- end
66
+ Rails::Generators.namespace
69
67
  end
70
68
 
71
69
  def namespaced?
@@ -2,6 +2,12 @@ Description:
2
2
  The 'rails new' command creates a new Rails application with a default
3
3
  directory structure and configuration at the path you specify.
4
4
 
5
+ You can specify extra command-line arguments to be used every time
6
+ 'rails new' runs in the .railsrc configuration file in your home directory.
7
+
8
+ Note that the arguments specified in the .railsrc file don't affect the
9
+ defaults values shown above in this help message.
10
+
5
11
  Example:
6
12
  rails new ~/Code/Ruby/weblog
7
13
 
@@ -38,7 +38,7 @@ module Rails
38
38
  end
39
39
 
40
40
  def readme
41
- copy_file "README"
41
+ copy_file "README", "README.rdoc"
42
42
  end
43
43
 
44
44
  def gemfile
@@ -122,10 +122,15 @@ module Rails
122
122
  end
123
123
 
124
124
  def vendor
125
+ vendor_javascripts
125
126
  vendor_stylesheets
126
127
  vendor_plugins
127
128
  end
128
129
 
130
+ def vendor_javascripts
131
+ empty_directory_with_gitkeep "vendor/assets/javascripts"
132
+ end
133
+
129
134
  def vendor_stylesheets
130
135
  empty_directory_with_gitkeep "vendor/assets/stylesheets"
131
136
  end
@@ -139,7 +144,6 @@ module Rails
139
144
  # We need to store the RAILS_DEV_PATH in a constant, otherwise the path
140
145
  # can change in Ruby 1.8.7 when we FileUtils.cd.
141
146
  RAILS_DEV_PATH = File.expand_path("../../../../../..", File.dirname(__FILE__))
142
-
143
147
  RESERVED_NAMES = %w[application destroy benchmarker profiler plugin runner test]
144
148
 
145
149
  class AppGenerator < AppBase
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  <%= rails_gemfile_entry -%>
4
4
 
@@ -13,6 +13,9 @@ source 'http://rubygems.org'
13
13
  # To use ActiveModel has_secure_password
14
14
  # gem 'bcrypt-ruby', '~> 3.0.0'
15
15
 
16
+ # To use Jbuilder templates for JSON
17
+ # gem 'jbuilder'
18
+
16
19
  # Use unicorn as the web server
17
20
  # gem 'unicorn'
18
21
 
@@ -21,5 +24,3 @@ source 'http://rubygems.org'
21
24
 
22
25
  # To use debugger
23
26
  # <%= ruby_debugger_gemfile_entry %>
24
-
25
- <%= turn_gemfile_entry -%>
@@ -1,9 +1,15 @@
1
- // This is a manifest file that'll be compiled into including all the files listed below.
2
- // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
- // be included in the compiled file accessible from http://example.com/assets/application.js
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
4
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
8
  // the compiled file.
6
9
  //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
7
13
  <% unless options[:skip_javascript] -%>
8
14
  //= require <%= options[:javascript] %>
9
15
  //= require <%= options[:javascript] %>_ujs
@@ -1,7 +1,13 @@
1
1
  /*
2
- * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
- * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
- * the top of the compiled file, but it's generally better to create a new file per style scope.
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
5
11
  *= require_self
6
- *= require_tree .
7
- */
12
+ *= require_tree .
13
+ */
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= camelized %></title>
5
- <%%= stylesheet_link_tag "application" %>
5
+ <%%= stylesheet_link_tag "application", :media => "all" %>
6
6
  <%%= javascript_include_tag "application" %>
7
7
  <%%= csrf_meta_tags %>
8
8
  </head>
@@ -49,6 +49,17 @@ module <%= app_const_base %>
49
49
  # Configure sensitive parameters which will be filtered from the log file.
50
50
  config.filter_parameters += [:password]
51
51
 
52
+ # Use SQL instead of Active Record's schema dumper when creating the database.
53
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
54
+ # like if you have constraints or database-specific column types
55
+ # config.active_record.schema_format = :sql
56
+
57
+ # Enforce whitelist mode for mass assignment.
58
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
59
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
60
+ # parameters by using an attr_accessible or attr_protected declaration.
61
+ # config.active_record.whitelist_attributes = true
62
+
52
63
  <% unless options.skip_sprockets? -%>
53
64
  # Enable the asset pipeline
54
65
  config.assets.enabled = true
@@ -1,4 +1,4 @@
1
- # PostgreSQL. Versions 7.4 and 8.x are supported.
1
+ # PostgreSQL. Versions 8.2 and up are supported.
2
2
  #
3
3
  # Configure Using Gemfile
4
4
  # gem 'activerecord-jdbcpostgresql-adapter'
@@ -1,4 +1,4 @@
1
- # PostgreSQL. Versions 7.4 and 8.x are supported.
1
+ # PostgreSQL. Versions 8.2 and up are supported.
2
2
  #
3
3
  # Install the pg driver:
4
4
  # gem install pg
@@ -2,7 +2,7 @@
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
5
+ # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
@@ -22,6 +22,15 @@
22
22
  # Only use best-standards-support built into browsers
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
+ <%- unless options.skip_active_record? -%>
26
+ # Raise exception on mass assignment protection for ActiveRecord models
27
+ config.active_record.mass_assignment_sanitizer = :strict
28
+
29
+ # Log the query plan for queries taking more than this (works
30
+ # with SQLite, MySQL, and PostgreSQL)
31
+ config.active_record.auto_explain_threshold_in_seconds = 0.5
32
+ <%- end -%>
33
+
25
34
  <%- unless options.skip_sprockets? -%>
26
35
  # Do not compress assets
27
36
  config.assets.compress = false
@@ -35,8 +35,11 @@
35
35
  # See everything in the log (default is :info)
36
36
  # config.log_level = :debug
37
37
 
38
+ # Prepend all log lines with the following tags
39
+ # config.log_tags = [ :subdomain, :uuid ]
40
+
38
41
  # Use a different logger for distributed setups
39
- # config.logger = SyslogLogger.new
42
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
40
43
 
41
44
  # Use a different cache store in production
42
45
  # config.cache_store = :mem_cache_store
@@ -61,4 +64,10 @@
61
64
 
62
65
  # Send deprecation notices to registered listeners
63
66
  config.active_support.deprecation = :notify
67
+
68
+ <%- unless options.skip_active_record? -%>
69
+ # Log the query plan for queries taking more than this (works
70
+ # with SQLite, MySQL, and PostgreSQL)
71
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
72
+ <%- end -%>
64
73
  end
@@ -2,9 +2,9 @@
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
5
+ # test suite. You never need to work with it otherwise. Remember that
6
6
  # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
7
+ # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
@@ -29,10 +29,10 @@
29
29
  # ActionMailer::Base.deliveries array.
30
30
  config.action_mailer.delivery_method = :test
31
31
 
32
- # Use SQL instead of Active Record's schema dumper when creating the test database.
33
- # This is necessary if your schema can't be completely dumped by the schema dumper,
34
- # like if you have constraints or database-specific column types
35
- # config.active_record.schema_format = :sql
32
+ <%- unless options.skip_active_record? -%>
33
+ # Raise exception on mass assignment protection for ActiveRecord models
34
+ config.active_record.mass_assignment_sanitizer = :strict
35
+ <%- end -%>
36
36
 
37
37
  # Print deprecation notices to the stderr
38
38
  config.active_support.deprecation = :stderr
@@ -8,3 +8,8 @@
8
8
  # inflect.irregular 'person', 'people'
9
9
  # inflect.uncountable %w( fish sheep )
10
10
  # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -54,5 +54,5 @@
54
54
 
55
55
  # This is a legacy wild controller route that's not recommended for RESTful applications.
56
56
  # Note: This route will make all actions in every controller accessible via GET requests.
57
- # match ':controller(/:action(/:id(.:format)))'
57
+ # match ':controller(/:action(/:id))(.:format)'
58
58
  end
@@ -20,7 +20,6 @@
20
20
  <!-- This file lives in public/500.html -->
21
21
  <div class="dialog">
22
22
  <h1>We're sorry, but something went wrong.</h1>
23
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
23
  </div>
25
24
  </body>
26
25
  </html>
@@ -59,7 +59,7 @@
59
59
 
60
60
 
61
61
  #header {
62
- background-image: url("/assets/rails.png");
62
+ background-image: url("assets/rails.png");
63
63
  background-repeat: no-repeat;
64
64
  background-position: top left;
65
65
  height: 64px;
@@ -3,7 +3,7 @@ class <%= class_name %>Controller < ApplicationController
3
3
  <% actions.each do |action| -%>
4
4
  def <%= action %>
5
5
  end
6
-
6
+ <%= "\n" unless action == actions.last -%>
7
7
  <% end -%>
8
8
  end
9
9
  <% end -%>
@@ -39,7 +39,7 @@ module Rails
39
39
  end
40
40
 
41
41
  def gitignore
42
- copy_file "gitignore", ".gitignore"
42
+ template "gitignore", ".gitignore"
43
43
  end
44
44
 
45
45
  def lib
@@ -246,8 +246,20 @@ task :default => :test
246
246
  "rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]"
247
247
  end
248
248
 
249
+ def original_name
250
+ @original_name ||= File.basename(destination_root)
251
+ end
252
+
249
253
  def name
250
- @name ||= File.basename(destination_root)
254
+ @name ||= begin
255
+ # same as ActiveSupport::Inflector#underscore except not replacing '-'
256
+ underscored = original_name.dup
257
+ underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
258
+ underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
259
+ underscored.downcase!
260
+
261
+ underscored
262
+ end
251
263
  end
252
264
 
253
265
  def camelized
@@ -256,11 +268,11 @@ task :default => :test
256
268
 
257
269
  def valid_const?
258
270
  if camelized =~ /^\d/
259
- raise Error, "Invalid plugin name #{name}. Please give a name which does not start with numbers."
271
+ raise Error, "Invalid plugin name #{original_name}. Please give a name which does not start with numbers."
260
272
  elsif RESERVED_NAMES.include?(name)
261
- raise Error, "Invalid plugin name #{name}. Please give a name which does not match one of the reserved rails words."
273
+ raise Error, "Invalid plugin name #{original_name}. Please give a name which does not match one of the reserved rails words."
262
274
  elsif Object.const_defined?(camelized)
263
- raise Error, "Invalid plugin name #{name}, constant #{camelized} is already in use. Please choose another plugin name."
275
+ raise Error, "Invalid plugin name #{original_name}, constant #{camelized} is already in use. Please choose another plugin name."
264
276
  end
265
277
  end
266
278
 
@@ -24,6 +24,7 @@ end
24
24
  APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
25
25
  load 'rails/tasks/engine.rake'
26
26
  <% end %>
27
+
27
28
  <% unless options[:skip_gemspec] -%>
28
29
 
29
30
  Bundler::GemHelper.install_tasks
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= camelized %></title>
5
- <%%= stylesheet_link_tag "<%= name %>/application" %>
5
+ <%%= stylesheet_link_tag "<%= name %>/application", :media => "all" %>
6
6
  <%%= javascript_include_tag "<%= name %>/application" %>
7
7
  <%%= csrf_meta_tags %>
8
8
  </head>
@@ -1,6 +1,7 @@
1
1
  .bundle/
2
2
  log/*.log
3
3
  pkg/
4
- test/dummy/db/*.sqlite3
5
- test/dummy/log/*.log
6
- test/dummy/tmp/
4
+ <%= dummy_path %>/db/*.sqlite3
5
+ <%= dummy_path %>/log/*.log
6
+ <%= dummy_path %>/tmp/
7
+ <%= dummy_path %>/.sass-cache
@@ -1,5 +1,5 @@
1
1
  module <%= camelized %>
2
- class Engine < Rails::Engine
2
+ class Engine < ::Rails::Engine
3
3
  <% if mountable? -%>
4
4
  isolate_namespace <%= camelized %>
5
5
  <% end -%>
@@ -4,7 +4,7 @@ require File.expand_path('../boot', __FILE__)
4
4
  require 'rails/all'
5
5
  <% else -%>
6
6
  # Pick the frameworks you want:
7
- <%= comment_if :skip_active_record %> require "active_record/railtie"
7
+ <%= comment_if :skip_active_record %>require "active_record/railtie"
8
8
  require "action_controller/railtie"
9
9
  require "action_mailer/railtie"
10
10
  require "active_resource/railtie"
@@ -1,5 +1,7 @@
1
- #!/usr/bin/env ruby
2
1
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
2
 
4
- ENGINE_PATH = File.expand_path('../..', __FILE__)
5
- load File.expand_path('../../<%= dummy_path %>/script/rails', __FILE__)
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/<%= name -%>/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -62,7 +62,7 @@ class <%= controller_class_name %>Controller < ApplicationController
62
62
  respond_to do |format|
63
63
  if @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %>
64
64
  format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
65
- format.json { head :ok }
65
+ format.json { head :no_content }
66
66
  else
67
67
  format.html { render <%= key_value :action, '"edit"' %> }
68
68
  format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
@@ -78,7 +78,7 @@ class <%= controller_class_name %>Controller < ApplicationController
78
78
 
79
79
  respond_to do |format|
80
80
  format.html { redirect_to <%= index_helper %>_url }
81
- format.json { head :ok }
81
+ format.json { head :no_content }
82
82
  end
83
83
  end
84
84
  end