railties 3.0.0.beta2 → 3.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/CHANGELOG +6 -2
  2. data/guides/{images → assets/images}/belongs_to.png +0 -0
  3. data/guides/{images → assets/images}/book_icon.gif +0 -0
  4. data/guides/{images → assets/images}/bullet.gif +0 -0
  5. data/guides/{images → assets/images}/challenge.png +0 -0
  6. data/guides/{images → assets/images}/chapters_icon.gif +0 -0
  7. data/guides/{images → assets/images}/check_bullet.gif +0 -0
  8. data/guides/{images → assets/images}/credits_pic_blank.gif +0 -0
  9. data/guides/{images → assets/images}/csrf.png +0 -0
  10. data/guides/{images → assets/images}/customized_error_messages.png +0 -0
  11. data/guides/{images → assets/images}/edge_badge.png +0 -0
  12. data/guides/{images → assets/images}/error_messages.png +0 -0
  13. data/guides/{images → assets/images}/feature_tile.gif +0 -0
  14. data/guides/{images → assets/images}/footer_tile.gif +0 -0
  15. data/guides/{images → assets/images}/fxn.png +0 -0
  16. data/guides/{images → assets/images}/grey_bullet.gif +0 -0
  17. data/guides/{images → assets/images}/habtm.png +0 -0
  18. data/guides/{images → assets/images}/has_many.png +0 -0
  19. data/guides/{images → assets/images}/has_many_through.png +0 -0
  20. data/guides/{images → assets/images}/has_one.png +0 -0
  21. data/guides/{images → assets/images}/has_one_through.png +0 -0
  22. data/guides/{images → assets/images}/header_backdrop.png +0 -0
  23. data/guides/{images → assets/images}/header_tile.gif +0 -0
  24. data/guides/{images → assets/images}/i18n/demo_localized_pirate.png +0 -0
  25. data/guides/{images → assets/images}/i18n/demo_translated_en.png +0 -0
  26. data/guides/{images → assets/images}/i18n/demo_translated_pirate.png +0 -0
  27. data/guides/{images → assets/images}/i18n/demo_translation_missing.png +0 -0
  28. data/guides/{images → assets/images}/i18n/demo_untranslated.png +0 -0
  29. data/guides/{images → assets/images}/icons/README +0 -0
  30. data/guides/{images → assets/images}/icons/callouts/1.png +0 -0
  31. data/guides/{images → assets/images}/icons/callouts/10.png +0 -0
  32. data/guides/{images → assets/images}/icons/callouts/11.png +0 -0
  33. data/guides/{images → assets/images}/icons/callouts/12.png +0 -0
  34. data/guides/{images → assets/images}/icons/callouts/13.png +0 -0
  35. data/guides/{images → assets/images}/icons/callouts/14.png +0 -0
  36. data/guides/{images → assets/images}/icons/callouts/15.png +0 -0
  37. data/guides/{images → assets/images}/icons/callouts/2.png +0 -0
  38. data/guides/{images → assets/images}/icons/callouts/3.png +0 -0
  39. data/guides/{images → assets/images}/icons/callouts/4.png +0 -0
  40. data/guides/{images → assets/images}/icons/callouts/5.png +0 -0
  41. data/guides/{images → assets/images}/icons/callouts/6.png +0 -0
  42. data/guides/{images → assets/images}/icons/callouts/7.png +0 -0
  43. data/guides/{images → assets/images}/icons/callouts/8.png +0 -0
  44. data/guides/{images → assets/images}/icons/callouts/9.png +0 -0
  45. data/guides/{images → assets/images}/icons/caution.png +0 -0
  46. data/guides/{images → assets/images}/icons/example.png +0 -0
  47. data/guides/{images → assets/images}/icons/home.png +0 -0
  48. data/guides/{images → assets/images}/icons/important.png +0 -0
  49. data/guides/{images → assets/images}/icons/next.png +0 -0
  50. data/guides/{images → assets/images}/icons/note.png +0 -0
  51. data/guides/{images → assets/images}/icons/prev.png +0 -0
  52. data/guides/{images → assets/images}/icons/tip.png +0 -0
  53. data/guides/{images → assets/images}/icons/up.png +0 -0
  54. data/guides/{images → assets/images}/icons/warning.png +0 -0
  55. data/guides/assets/images/jaimeiniesta.jpg +0 -0
  56. data/guides/{images → assets/images}/nav_arrow.gif +0 -0
  57. data/guides/{images → assets/images}/polymorphic.png +0 -0
  58. data/guides/{images → assets/images}/posts_index.png +0 -0
  59. data/guides/{images → assets/images}/rails_guides_logo.gif +0 -0
  60. data/guides/{images → assets/images}/rails_logo_remix.gif +0 -0
  61. data/guides/{images → assets/images}/rails_welcome.png +0 -0
  62. data/guides/{images → assets/images}/session_fixation.png +0 -0
  63. data/guides/{images → assets/images}/tab_grey.gif +0 -0
  64. data/guides/{images → assets/images}/tab_info.gif +0 -0
  65. data/guides/{images → assets/images}/tab_note.gif +0 -0
  66. data/guides/{images → assets/images}/tab_red.gif +0 -0
  67. data/guides/{images → assets/images}/tab_yellow.gif +0 -0
  68. data/guides/{images → assets/images}/tab_yellow.png +0 -0
  69. data/guides/{images → assets/images}/validation_error_messages.png +0 -0
  70. data/guides/{files → assets}/javascripts/code_highlighter.js +0 -0
  71. data/guides/{files → assets}/javascripts/guides.js +0 -0
  72. data/guides/{files → assets}/javascripts/highlighters.js +0 -0
  73. data/guides/{files → assets}/stylesheets/main.css +26 -15
  74. data/guides/{files → assets}/stylesheets/print.css +0 -0
  75. data/guides/{files → assets}/stylesheets/reset.css +0 -0
  76. data/guides/{files → assets}/stylesheets/style.css +0 -0
  77. data/guides/{files → assets}/stylesheets/syntax.css +0 -0
  78. data/guides/rails_guides/generator.rb +79 -29
  79. data/guides/rails_guides/helpers.rb +2 -2
  80. data/guides/rails_guides/indexer.rb +24 -11
  81. data/guides/source/2_2_release_notes.textile +1 -1
  82. data/guides/source/3_0_release_notes.textile +27 -1
  83. data/guides/source/action_controller_overview.textile +7 -7
  84. data/guides/source/action_view_overview.textile +15 -15
  85. data/guides/source/active_record_querying.textile +4 -3
  86. data/guides/source/active_support_core_extensions.textile +6 -6
  87. data/guides/source/activerecord_validations_callbacks.textile +1 -1
  88. data/guides/source/association_basics.textile +83 -82
  89. data/guides/source/command_line.textile +16 -12
  90. data/guides/source/configuring.textile +1 -1
  91. data/guides/source/contribute.textile +1 -1
  92. data/guides/source/contributing_to_rails.textile +3 -4
  93. data/guides/source/credits.html.erb +64 -0
  94. data/guides/source/debugging_rails_applications.textile +2 -1
  95. data/guides/source/form_helpers.textile +15 -13
  96. data/guides/source/getting_started.textile +9 -8
  97. data/guides/source/index.html.erb +154 -0
  98. data/guides/source/initialization.textile +4138 -0
  99. data/guides/source/layout.html.erb +15 -7
  100. data/guides/source/layouts_and_rendering.textile +6 -5
  101. data/guides/source/nested_model_forms.textile +3 -3
  102. data/guides/source/performance_testing.textile +4 -4
  103. data/guides/source/plugins.textile +15 -14
  104. data/guides/source/rails_on_rack.textile +1 -1
  105. data/guides/source/routing.textile +379 -490
  106. data/guides/source/security.textile +5 -5
  107. data/guides/source/testing.textile +3 -2
  108. data/lib/rails.rb +7 -2
  109. data/lib/rails/application.rb +9 -2
  110. data/lib/rails/application/configuration.rb +19 -10
  111. data/lib/rails/application/finisher.rb +4 -0
  112. data/lib/rails/backtrace_cleaner.rb +1 -1
  113. data/{bin/rails → lib/rails/cli.rb} +0 -0
  114. data/lib/rails/commands/runner.rb +1 -1
  115. data/lib/rails/configuration.rb +12 -0
  116. data/lib/rails/engine.rb +6 -10
  117. data/lib/rails/engine/configuration.rb +2 -3
  118. data/lib/rails/generators.rb +1 -6
  119. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +0 -7
  120. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +10 -1
  121. data/lib/rails/generators/erb/scaffold/templates/show.html.erb +2 -0
  122. data/lib/rails/generators/migration.rb +3 -3
  123. data/lib/rails/generators/rails/app/app_generator.rb +1 -1
  124. data/lib/rails/generators/rails/app/templates/Gemfile +2 -0
  125. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb +1 -0
  126. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +14 -0
  127. data/lib/rails/generators/rails/app/templates/config/application.rb +4 -1
  128. data/lib/rails/generators/rails/app/templates/config/boot.rb +5 -13
  129. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +3 -0
  130. data/lib/rails/generators/rails/app/templates/config/initializers/{cookie_verification_secret.rb.tt → secret_token.rb.tt} +1 -1
  131. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -3
  132. data/lib/rails/generators/rails/app/templates/public/index.html +2 -1
  133. data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +41 -32
  134. data/lib/rails/generators/rails/app/templates/test/{test_helper.rb → test_helper.rb.tt} +2 -0
  135. data/lib/rails/generators/rails/model/USAGE +15 -0
  136. data/lib/rails/generators/rails/stylesheets/templates/scaffold.css +3 -8
  137. data/lib/rails/paths.rb +17 -5
  138. data/lib/rails/plugin.rb +1 -1
  139. data/lib/rails/railtie.rb +3 -25
  140. data/lib/rails/test_unit/testing.rake +11 -7
  141. data/lib/rails/version.rb +1 -1
  142. data/lib/rails/webrick_server.rb +2 -2
  143. metadata +93 -92
  144. data/guides/source/credits.textile.erb +0 -60
  145. data/guides/source/index.textile.erb +0 -139
  146. data/lib/rails/generators/erb/scaffold/templates/layout.html.erb +0 -17
  147. data/lib/rails/generators/rails/app/templates/app/views/layouts/.empty_directory +0 -0
@@ -611,7 +611,7 @@ h4. SQL Injection
611
611
 
612
612
  -- _Thanks to clever methods, this is hardly a problem in most Rails applications. However, this is a very devastating and common attack in web applications, so it is important to understand the problem._
613
613
 
614
- h5. Introduction
614
+ h5(#sql-injection-introduction). Introduction
615
615
 
616
616
  SQL injection attacks aim at influencing database queries by manipulating web application parameters. A popular goal of SQL injection attacks is to bypass authorization. Another goal is to carry out data manipulation or reading arbitrary data. Here is an example of how not to use user input data in a query:
617
617
 
@@ -668,7 +668,7 @@ The result won't be a list of projects (because there is no project with an empt
668
668
 
669
669
  Also, the second query renames some columns with the AS statement so that the web application displays the values from the user table. Be sure to update your Rails "to at least 2.1.1":http://www.rorsecurity.info/2008/09/08/sql-injection-issue-in-limit-and-offset-parameter/.
670
670
 
671
- h5. Countermeasures
671
+ h5(#sql-injection-countermeasures). Countermeasures
672
672
 
673
673
  Ruby on Rails has a built in filter for special SQL characters, which will escape ' , " , NULL character and line breaks. <em class="highlight">Using +Model.find(id)+ or +Model.find_by_some thing(something)+ automatically applies this countermeasure</em>. But in SQL fragments, especially <em class="highlight">in conditions fragments (+:conditions => "..."+), the +connection.execute()+ or +Model.find_by_sql()+ methods, it has to be applied manually</em>.
674
674
 
@@ -760,7 +760,7 @@ http://www.cbsnews.com/stories/2002/02/15/weather_local/main501644.shtml?zipcode
760
760
  <script src=http://www.securitylab.ru/test/sc.js></script><!--
761
761
  </plain>
762
762
 
763
- h6. Countermeasures
763
+ h6(#html-injection-countermeasures). Countermeasures
764
764
 
765
765
  _(highlight)It is very important to filter malicious input, but it is also important to escape the output of the web application_.
766
766
 
@@ -850,7 +850,7 @@ In the end, he got a 4 KB worm, which he injected into his profile page.
850
850
 
851
851
  The "moz-binding":http://www.securiteam.com/securitynews/5LP051FHPE.html CSS property proved to be another way to introduce JavaScript in CSS in Gecko-based browsers (Firefox, for example).
852
852
 
853
- h5. Countermeasures
853
+ h5(#css-injection-countermeasures). Countermeasures
854
854
 
855
855
  This example, again, showed that a blacklist filter is never complete. However, as custom CSS in web applications is a quite rare feature, I am not aware of a whitelist CSS filter. _(highlight)If you want to allow custom colours or images, you can allow the user to choose them and build the CSS in the web application_. Use Rails' +sanitize()+ method as a model for a whitelist CSS filter, if you really need one.
856
856
 
@@ -879,7 +879,7 @@ RedCloth.new("<a href='javascript:alert(1)'>hello</a>", [:filter_html]).to_html
879
879
  # => "<p><a href="javascript:alert(1)">hello</a></p>"
880
880
  </ruby>
881
881
 
882
- h5. Countermeasures
882
+ h5(#textile-injection-countermeasures). Countermeasures
883
883
 
884
884
  It is recommended to _(highlight)use RedCloth in combination with a whitelist input filter_, as described in the countermeasures against XSS section.
885
885
 
@@ -84,7 +84,7 @@ h5. ERb'in It Up
84
84
  ERb allows you embed ruby code within templates. Both the YAML and CSV fixture formats are pre-processed with ERb when you load fixtures. This allows you to use Ruby to help you generate some sample data.
85
85
 
86
86
  <erb>
87
- <% earth_size = 20 -%>
87
+ <% earth_size = 20 %>
88
88
  mercury:
89
89
  size: <%= earth_size / 50 %>
90
90
  brightest_on: <%= 113.days.ago.to_s(:db) %>
@@ -411,7 +411,7 @@ NOTE: +assert_valid(record)+ has been deprecated. Please use +assert(record.vali
411
411
  |_.Assertion |_.Purpose|
412
412
  |+assert_valid(record)+ |Ensures that the passed record is valid by Active Record standards and returns any error messages if it is not.|
413
413
  |+assert_difference(expressions, difference = 1, message = nil) {...}+ |Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.|
414
- |+assert_no_difference(expressions, message = nil, &block)+ |Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.|
414
+ |+assert_no_difference(expressions, message = nil, &amp;block)+ |Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.|
415
415
  |+assert_recognizes(expected_options, path, extras={}, message=nil)+ |Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.|
416
416
  |+assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)+ |Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.|
417
417
  |+assert_response(type, message = nil)+ |Asserts that the response comes with a specific status code. You can specify +:success+ to indicate 200, +:redirect+ to indicate 300-399, +:missing+ to indicate 404, or +:error+ to match the 500-599 range|
@@ -940,6 +940,7 @@ h3. Changelog
940
940
 
941
941
  "Lighthouse ticket":http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/8
942
942
 
943
+ * April 4, 2010: Fixed document to validate XHTML 1.0 Strict. "Jaime Iniesta":http://jaimeiniesta.com
943
944
  * November 13, 2008: Revised based on feedback from Pratik Naik by "Akshay Surve":credits.html#asurve (not yet approved for publication)
944
945
  * October 14, 2008: Edit and formatting pass by "Mike Gunderloy":credits.html#mgunderloy (not yet approved for publication)
945
946
  * October 12, 2008: First draft by "Akshay Surve":credits.html#asurve (not yet approved for publication)
@@ -79,6 +79,10 @@ module Rails
79
79
  @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
80
80
  end
81
81
 
82
+ def env=(environment)
83
+ @_env = ActiveSupport::StringInquirer.new(environment)
84
+ end
85
+
82
86
  def cache
83
87
  RAILS_CACHE
84
88
  end
@@ -88,11 +92,12 @@ module Rails
88
92
  end
89
93
 
90
94
  def public_path
91
- @@public_path ||= self.root ? File.join(self.root, "public") : "public"
95
+ application && application.paths.public.to_a.first
92
96
  end
93
97
 
94
98
  def public_path=(path)
95
- @@public_path = path
99
+ ActiveSupport::Deprecation.warn "Setting Rails.public_path= is deprecated. " <<
100
+ "Please set paths.public = in config/application.rb instead.", caller
96
101
  end
97
102
  end
98
103
  end
@@ -1,3 +1,4 @@
1
+ require 'active_support/core_ext/hash/reverse_merge'
1
2
  require 'fileutils'
2
3
  require 'rails/plugin'
3
4
  require 'rails/engine'
@@ -128,8 +129,14 @@ module Rails
128
129
  end
129
130
 
130
131
  def call(env)
131
- env["action_dispatch.parameter_filter"] = config.filter_parameters
132
- app.call(env)
132
+ app.call(env.reverse_merge!(env_defaults))
133
+ end
134
+
135
+ def env_defaults
136
+ @env_defaults ||= {
137
+ "action_dispatch.parameter_filter" => config.filter_parameters,
138
+ "action_dispatch.secret_token" => config.secret_token
139
+ }
133
140
  end
134
141
 
135
142
  def initializers
@@ -6,21 +6,29 @@ module Rails
6
6
  include ::Rails::Configuration::Deprecated
7
7
 
8
8
  attr_accessor :allow_concurrency, :cache_classes, :cache_store,
9
- :cookie_secret, :consider_all_requests_local, :dependency_loading,
9
+ :encoding, :consider_all_requests_local, :dependency_loading,
10
10
  :filter_parameters, :log_level, :logger, :metals,
11
11
  :plugins, :preload_frameworks, :reload_engines, :reload_plugins,
12
- :serve_static_assets, :time_zone, :whiny_nils
12
+ :secret_token, :serve_static_assets, :time_zone, :whiny_nils
13
13
 
14
14
  def initialize(*)
15
15
  super
16
- @allow_concurrency = false
17
- @filter_parameters = []
18
- @dependency_loading = true
16
+ @allow_concurrency = false
17
+ @consider_all_requests_local = false
18
+ @encoding = "utf-8"
19
+ @filter_parameters = []
20
+ @dependency_loading = true
19
21
  @serve_static_assets = true
20
- @time_zone = "UTC"
21
- @consider_all_requests_local = true
22
22
  @session_store = :cookie_store
23
23
  @session_options = {}
24
+ @time_zone = "UTC"
25
+ end
26
+
27
+ def encoding=(value)
28
+ @encoding = value
29
+ if defined?(Encoding) && Encoding.respond_to?(:default_external=)
30
+ Encoding.default_external = value
31
+ end
24
32
  end
25
33
 
26
34
  def middleware
@@ -37,6 +45,7 @@ module Rails
37
45
  paths.app.controllers << builtin_controller if builtin_controller
38
46
  paths.config.database "config/database.yml"
39
47
  paths.config.environment "config/environments", :glob => "#{Rails.env}.rb"
48
+ paths.lib.templates "lib/templates"
40
49
  paths.log "log/#{Rails.env}.log"
41
50
  paths.tmp "tmp"
42
51
  paths.tmp.cache "tmp/cache"
@@ -123,16 +132,16 @@ module Rails
123
132
 
124
133
  def session_options
125
134
  return @session_options unless @session_store == :cookie_store
126
- @session_options.merge(:secret => @cookie_secret)
135
+ @session_options.merge(:secret => @secret_token)
127
136
  end
128
137
 
129
138
  def default_middleware_stack
130
139
  ActionDispatch::MiddlewareStack.new.tap do |middleware|
131
- middleware.use('::ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { serve_static_assets })
140
+ middleware.use('::ActionDispatch::Static', lambda { paths.public.to_a.first }, :if => lambda { serve_static_assets })
132
141
  middleware.use('::Rack::Lock', :if => lambda { !allow_concurrency })
133
142
  middleware.use('::Rack::Runtime')
134
143
  middleware.use('::Rails::Rack::Logger')
135
- middleware.use('::ActionDispatch::ShowExceptions', lambda { consider_all_requests_local })
144
+ middleware.use('::ActionDispatch::ShowExceptions', lambda { consider_all_requests_local }, :if => lambda { action_dispatch.show_exceptions })
136
145
  middleware.use("::ActionDispatch::RemoteIp", lambda { action_dispatch.ip_spoofing_check }, lambda { action_dispatch.trusted_proxies })
137
146
  middleware.use('::Rack::Sendfile', lambda { action_dispatch.x_sendfile_header })
138
147
  middleware.use('::ActionDispatch::Callbacks', lambda { !cache_classes })
@@ -3,6 +3,10 @@ module Rails
3
3
  module Finisher
4
4
  include Initializable
5
5
 
6
+ initializer :add_generator_templates do
7
+ config.generators.templates.unshift(*paths.lib.templates.to_a)
8
+ end
9
+
6
10
  initializer :ensure_load_once_paths_as_subset do
7
11
  extra = ActiveSupport::Dependencies.load_once_paths -
8
12
  ActiveSupport::Dependencies.load_paths
@@ -13,7 +13,7 @@ module Rails
13
13
 
14
14
  add_gem_filters
15
15
 
16
- add_silencer { |line| !APP_DIRS.any? { |dir| line =~ /^#{dir}/ } }
16
+ add_silencer { |line| !APP_DIRS.any? { |dir| line =~ /^\/?#{dir}/ } }
17
17
  end
18
18
 
19
19
  private
File without changes
@@ -18,7 +18,7 @@ ARGV.clone.options do |opts|
18
18
  opts.on("-h", "--help",
19
19
  "Show this help message.") { $stderr.puts opts; exit }
20
20
 
21
- if RUBY_PLATFORM !~ /mswin/
21
+ if RUBY_PLATFORM !~ /mswin|mingw/
22
22
  opts.separator ""
23
23
  opts.separator "You can also use runner as a shebang line for your scripts like this:"
24
24
  opts.separator "-------------------------------------------------------------"
@@ -104,6 +104,18 @@ module Rails
104
104
  "please do paths.app.controllers instead", caller
105
105
  paths.app.controllers.to_a.uniq
106
106
  end
107
+
108
+ def cookie_secret=(value)
109
+ ActiveSupport::Deprecation.warn "config.cookie_secret= is deprecated, " <<
110
+ "please use config.secret_token= instead", caller
111
+ self.secret_token = value
112
+ end
113
+
114
+ def cookie_secret
115
+ ActiveSupport::Deprecation.warn "config.cookie_secret is deprecated, " <<
116
+ "please use config.secret_token instead", caller
117
+ self.secret_token
118
+ end
107
119
  end
108
120
  end
109
121
  end
@@ -20,7 +20,6 @@ module Rails
20
20
  # # lib/my_engine.rb
21
21
  # module MyEngine
22
22
  # class Engine < Rails::Engine
23
- # engine_name :my_engine
24
23
  # end
25
24
  # end
26
25
  #
@@ -38,11 +37,12 @@ module Rails
38
37
  # Example:
39
38
  #
40
39
  # class MyEngine < Rails::Engine
41
- # # config.middleware is shared configururation
42
- # config.middleware.use MyEngine::Middleware
43
- #
44
40
  # # Add a load path for this specific Engine
45
41
  # config.load_paths << File.expand_path("../lib/some/path", __FILE__)
42
+ #
43
+ # initializer "my_engine.add_middleware" do |app|
44
+ # app.middlewares.use MyEngine::Middleware
45
+ # end
46
46
  # end
47
47
  #
48
48
  # == Paths
@@ -193,17 +193,13 @@ module Rails
193
193
  app.metal_loader.paths.unshift(*paths.app.metals.to_a)
194
194
  end
195
195
 
196
- initializer :add_generator_templates do |app|
197
- config.generators.templates.unshift(*paths.lib.templates.to_a)
198
- end
199
-
200
- initializer :load_application_initializers do
196
+ initializer :load_config_initializers do
201
197
  paths.config.initializers.to_a.sort.each do |initializer|
202
198
  load(initializer)
203
199
  end
204
200
  end
205
201
 
206
- initializer :load_application_classes do |app|
202
+ initializer :load_app_classes do |app|
207
203
  next if $rails_rake_task
208
204
 
209
205
  if app.config.cache_classes
@@ -20,10 +20,9 @@ module Rails
20
20
  paths.app.models "app/models", :eager_load => true
21
21
  paths.app.mailers "app/mailers", :eager_load => true
22
22
  paths.app.metals "app/metal", :eager_load => true
23
- paths.app.views "app/views", :eager_load => true
23
+ paths.app.views "app/views"
24
24
  paths.lib "lib", :load_path => true
25
25
  paths.lib.tasks "lib/tasks", :glob => "**/*.rake"
26
- paths.lib.templates "lib/templates"
27
26
  paths.config "config"
28
27
  paths.config.initializers "config/initializers", :glob => "**/*.rb"
29
28
  paths.config.locales "config/locales", :glob => "*.{rb,yml}"
@@ -44,7 +43,7 @@ module Rails
44
43
  end
45
44
 
46
45
  def load_once_paths
47
- @eager_load_paths ||= paths.load_once
46
+ @load_once_paths ||= paths.load_once
48
47
  end
49
48
 
50
49
  def load_paths
@@ -3,7 +3,7 @@ $:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.inc
3
3
 
4
4
  require 'active_support'
5
5
  require 'active_support/core_ext/object/blank'
6
- require 'active_support/core_ext/object/singleton_class'
6
+ require 'active_support/core_ext/kernel/singleton_class'
7
7
  require 'active_support/core_ext/array/extract_options'
8
8
  require 'active_support/core_ext/hash/deep_merge'
9
9
  require 'active_support/core_ext/module/attribute_accessors'
@@ -42,14 +42,9 @@ module Rails
42
42
  }
43
43
 
44
44
  DEFAULT_OPTIONS = {
45
- :erb => {
46
- :layout => true
47
- },
48
-
49
45
  :rails => {
50
46
  :force_plural => false,
51
47
  :helper => true,
52
- :layout => true,
53
48
  :orm => nil,
54
49
  :integration_tool => nil,
55
50
  :performance_tool => nil,
@@ -8,7 +8,6 @@ module Erb
8
8
 
9
9
  argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
10
10
 
11
- class_option :layout, :type => :boolean
12
11
  class_option :singleton, :type => :boolean, :desc => "Supply to skip index view"
13
12
 
14
13
  def create_root_folder
@@ -25,12 +24,6 @@ module Erb
25
24
  end
26
25
  end
27
26
 
28
- def copy_layout_file
29
- return unless options[:layout]
30
- template filename_with_extensions(:layout),
31
- File.join("app/views/layouts", controller_class_path, filename_with_extensions(controller_file_name))
32
- end
33
-
34
27
  protected
35
28
 
36
29
  def available_views
@@ -1,5 +1,14 @@
1
1
  <%%= form_for(@<%= singular_name %>) do |f| %>
2
- <%%= f.error_messages %>
2
+ <%% if @<%= singular_name %>.errors.any? %>
3
+ <div id="errorExplanation">
4
+ <h2><%%= pluralize(@<%= singular_name %>.errors.count, "error") %> prohibited this <%= singular_name %> from being saved:</h2>
5
+ <ul>
6
+ <%% @<%= singular_name %>.errors.full_messages.each do |msg| %>
7
+ <li><%%= msg %></li>
8
+ <%% end %>
9
+ </ul>
10
+ </div>
11
+ <%% end %>
3
12
 
4
13
  <% for attribute in attributes -%>
5
14
  <div class="field">
@@ -1,3 +1,5 @@
1
+ <p class="notice"><%%= notice %></p>
2
+
1
3
  <% for attribute in attributes -%>
2
4
  <p>
3
5
  <b><%= attribute.human_name %>:</b>
@@ -2,7 +2,7 @@ module Rails
2
2
  module Generators
3
3
  # Holds common methods for migrations. It assumes that migrations has the
4
4
  # [0-9]*_name format and can be used by another frameworks (like Sequel)
5
- # just by implementing the next migration number method.
5
+ # just by implementing the next migration version method.
6
6
  #
7
7
  module Migration
8
8
  attr_reader :migration_number, :migration_file_name, :migration_class_name
@@ -32,10 +32,10 @@ module Rails
32
32
  end
33
33
 
34
34
  # Creates a migration template at the given destination. The difference
35
- # to the default template method is that the migration number is appended
35
+ # to the default template method is that the migration version is appended
36
36
  # to the destination file name.
37
37
  #
38
- # The migration number, migration file name, migration class name are
38
+ # The migration version, migration file name, migration class name are
39
39
  # available as instance variables in the template to be rendered.
40
40
  #
41
41
  # ==== Examples
@@ -78,7 +78,7 @@ module Rails::Generators
78
78
  end
79
79
 
80
80
  def create_app_files
81
- directory "app"
81
+ directory 'app'
82
82
  end
83
83
 
84
84
  def create_config_files
@@ -2,8 +2,10 @@ source 'http://rubygems.org'
2
2
 
3
3
  <%- if options.dev? -%>
4
4
  gem 'rails', :path => '<%= Rails::Generators::RAILS_DEV_PATH %>'
5
+ gem 'arel', :git => 'git://github.com/rails/arel.git'
5
6
  <%- elsif options.edge? -%>
6
7
  gem 'rails', :git => 'git://github.com/rails/rails.git'
8
+ gem 'arel', :git => 'git://github.com/rails/arel.git'
7
9
  <%- else -%>
8
10
  gem 'rails', '<%= Rails::VERSION::STRING %>'
9
11
 
@@ -1,3 +1,4 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
+ layout 'application'
3
4
  end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= app_const_base %></title>
5
+ <%%= stylesheet_link_tag :all %>
6
+ <%%= javascript_include_tag :defaults %>
7
+ <%%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -46,7 +46,10 @@ module <%= app_const_base %>
46
46
  # g.test_framework :test_unit, :fixture => true
47
47
  # end
48
48
 
49
+ # Configure the default encoding used in templates for Ruby 1.9.
50
+ config.encoding = "utf-8"
51
+
49
52
  # Configure sensitive parameters which will be filtered from the log file.
50
- config.filter_parameters << :password
53
+ config.filter_parameters += [:password]
51
54
  end
52
55
  end