Permalink
Browse files

Merge remote branch 'rails/master'

Conflicts:
	actionpack/lib/abstract_controller/base.rb
  • Loading branch information...
2 parents 31cadc7 + 50d37a7 commit 207fa59675cb624dde0e01c1d57597f752cdf095 @fxn fxn committed Jun 20, 2010
Showing with 1,885 additions and 954 deletions.
  1. +1 −4 Gemfile
  2. +13 −2 Rakefile
  3. +3 −2 actionmailer/Rakefile
  4. +10 −0 actionpack/CHANGELOG
  5. +2 −1 actionpack/Rakefile
  6. +2 −11 actionpack/lib/abstract_controller/base.rb
  7. +9 −2 actionpack/lib/action_controller/metal.rb
  8. +0 −4 actionpack/lib/action_controller/metal/rack_delegation.rb
  9. +2 −1 actionpack/lib/action_controller/polymorphic_routes.rb
  10. +11 −3 actionpack/lib/action_controller/record_identifier.rb
  11. 0 actionpack/lib/action_dispatch/http/request.rb
  12. +4 −4 actionpack/lib/action_dispatch/middleware/callbacks.rb
  13. +1 −1 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
  14. +1 −1 actionpack/lib/action_dispatch/railtie.rb
  15. +287 −159 actionpack/lib/action_dispatch/routing/mapper.rb
  16. +4 −2 actionpack/lib/action_view/helpers/date_helper.rb
  17. +1 −1 actionpack/lib/action_view/helpers/form_helper.rb
  18. +1 −1 actionpack/lib/action_view/helpers/form_options_helper.rb
  19. +18 −14 actionpack/lib/action_view/helpers/text_helper.rb
  20. +1 −1 actionpack/lib/action_view/render/partials.rb
  21. +1 −0 actionpack/lib/action_view/test_case.rb
  22. +1 −0 actionpack/test/activerecord/polymorphic_routes_test.rb
  23. +21 −2 actionpack/test/controller/record_identifier_test.rb
  24. +11 −0 actionpack/test/controller/render_test.rb
  25. +235 −2 actionpack/test/dispatch/routing_test.rb
  26. +1 −0 actionpack/test/fixtures/fun/games/_form.erb
  27. +27 −0 actionpack/test/template/date_helper_test.rb
  28. +20 −0 actionpack/test/template/form_helper_test.rb
  29. +12 −18 actionpack/test/template/form_options_helper_test.rb
  30. +8 −0 actionpack/test/template/test_case_test.rb
  31. +36 −53 actionpack/test/template/text_helper_test.rb
  32. +3 −0 activemodel/Rakefile
  33. +9 −2 activemodel/lib/active_model/validations.rb
  34. +57 −0 activemodel/lib/active_model/validations/callbacks.rb
  35. +77 −0 activemodel/test/cases/validations/callbacks_test.rb
  36. +5 −0 activerecord/CHANGELOG
  37. +2 −0 activerecord/RUNNING_UNIT_TESTS
  38. +3 −2 activerecord/Rakefile
  39. 0 activerecord/examples/performance.rb
  40. +1 −1 activerecord/lib/active_record/associations.rb
  41. +5 −1 activerecord/lib/active_record/associations/association_collection.rb
  42. +4 −32 activerecord/lib/active_record/base.rb
  43. +2 −25 activerecord/lib/active_record/callbacks.rb
  44. +2 −2 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  45. 0 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  46. +6 −1 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  47. +2 −1 activerecord/lib/active_record/observer.rb
  48. +0 −1 activerecord/lib/active_record/railtie.rb
  49. +46 −46 activerecord/lib/active_record/relation/query_methods.rb
  50. +1 −0 activerecord/lib/active_record/transactions.rb
  51. +2 −2 activerecord/lib/active_record/validations.rb
  52. +8 −4 activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
  53. +7 −8 activerecord/test/cases/adapter_test.rb
  54. +0 −1 activerecord/test/cases/autosave_association_test.rb
  55. +0 −4 activerecord/test/cases/base_test.rb
  56. 0 activerecord/test/cases/counter_cache_test.rb
  57. +1 −1 activerecord/test/cases/migration_test.rb
  58. +21 −0 activerecord/test/cases/nested_attributes_test.rb
  59. +11 −3 activerecord/test/cases/transaction_callbacks_test.rb
  60. +2 −2 activerecord/test/models/pirate.rb
  61. +3 −2 activeresource/Rakefile
  62. +4 −0 activesupport/CHANGELOG
  63. +3 −1 activesupport/Rakefile
  64. 0 activesupport/bin/generate_tables
  65. +3 −0 activesupport/lib/active_support.rb
  66. +7 −3 activesupport/lib/active_support/callbacks.rb
  67. +5 −5 activesupport/lib/active_support/core_ext/class/subclasses.rb
  68. +2 −0 activesupport/lib/active_support/core_ext/date_time/zones.rb
  69. 0 activesupport/lib/active_support/core_ext/object/to_param.rb
  70. +2 −0 activesupport/lib/active_support/core_ext/time/zones.rb
  71. +39 −0 activesupport/lib/active_support/descendants_tracker.rb
  72. +37 −0 activesupport/lib/active_support/file_update_checker.rb
  73. +1 −0 activesupport/lib/active_support/i18n.rb
  74. +80 −0 activesupport/lib/active_support/i18n_railtie.rb
  75. +1 −1 activesupport/lib/active_support/json/backends/yajl.rb
  76. +20 −14 activesupport/lib/active_support/multibyte/chars.rb
  77. +1 −71 activesupport/lib/active_support/railtie.rb
  78. +53 −69 activesupport/lib/active_support/testing/performance.rb
  79. +7 −0 activesupport/test/core_ext/time_with_zone_test.rb
  80. +75 −0 activesupport/test/descendants_tracker_test.rb
  81. +56 −0 activesupport/test/file_update_checker_test.rb
  82. +14 −0 activesupport/test/multibyte_chars_test.rb
  83. +2 −0 bin/rails
  84. +132 −127 doc/template/horo.rb
  85. +2 −0 railties/Rakefile
  86. 0 railties/guides/assets/javascripts/code_highlighter.js
  87. 0 railties/guides/assets/javascripts/guides.js
  88. 0 railties/guides/assets/stylesheets/print.css
  89. 0 railties/guides/assets/stylesheets/reset.css
  90. 0 railties/guides/assets/stylesheets/style.css
  91. +26 −6 railties/lib/rails/application.rb
  92. +2 −0 railties/lib/rails/application/bootstrap.rb
  93. +0 −46 railties/lib/rails/application/routes_reloader.rb
  94. 0 railties/lib/rails/commands/generate.rb
  95. +2 −1 railties/lib/rails/commands/server.rb
  96. +1 −1 railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb
  97. +1 −1 railties/lib/rails/generators/erb/scaffold/templates/new.html.erb
  98. +1 −1 railties/lib/rails/generators/erb/scaffold/templates/show.html.erb
  99. +8 −0 railties/lib/rails/generators/named_base.rb
  100. +4 −4 railties/lib/rails/generators/rails/app/templates/README
  101. 0 railties/lib/rails/generators/rails/app/templates/Rakefile
  102. +36 −24 railties/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml
  103. +1 −1 railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml
  104. +1 −1 railties/lib/rails/generators/rails/app/templates/config/databases/oracle.yml
  105. +1 −1 railties/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb
  106. +1 −1 railties/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt
  107. +1 −1 railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
  108. +1 −1 railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
  109. +114 −19 railties/test/application/initializers/i18n_test.rb
  110. +1 −1 railties/test/application/initializers/load_path_test.rb
  111. +73 −0 railties/test/application/loading_test.rb
  112. +0 −33 railties/test/application/model_initialization_test.rb
  113. +1 −1 railties/test/application/rake_test.rb
  114. +14 −0 railties/test/application/routing_test.rb
  115. +15 −0 railties/test/generators/migration_generator_test.rb
  116. +10 −0 railties/test/generators/named_base_test.rb
  117. +0 −89 railties/test/railties/i18n_railtie_test.rb
View
@@ -5,6 +5,7 @@ gem "rails", :path => File.dirname(__FILE__)
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
+gem "rdoc", "2.2"
mri = !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
if mri && RUBY_VERSION < '1.9'
@@ -44,10 +45,6 @@ elsif RUBY_ENGINE == "jruby"
end
end
-group :documentation do
- gem 'rdoc', '2.1'
-end
-
if ENV['CI']
gem "nokogiri", ">= 1.4.0"
View
@@ -1,3 +1,6 @@
+gem 'rdoc', '= 2.2'
+require 'rdoc'
+
require 'rake'
require 'rake/rdoctask'
require 'rake/gempackagetask'
@@ -68,7 +71,15 @@ Rake::RDocTask.new do |rdoc|
rdoc.options << '--charset' << 'utf-8'
rdoc.options << '--main' << 'railties/README'
- rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : './doc/template/horo'
+ # Workaround: RDoc assumes that rdoc.template can be required, and that
+ # rdoc.template.upcase is a constant living in RDoc::Generator::HTML
+ # which holds the actual template class.
+ #
+ # We put 'doc/template' in the load path to be able to set the template
+ # to the string 'horo' and thus meet those RDoc's assumptions.
+ $:.unshift('doc/template')
+
+ rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : 'horo'
rdoc.rdoc_files.include('railties/CHANGELOG')
rdoc.rdoc_files.include('railties/MIT-LICENSE')
@@ -117,7 +128,7 @@ end
desc "Publish API docs for Rails as a whole and for each component"
task :pdoc => :rdoc do
require 'rake/contrib/sshpublisher'
- Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/api", "doc/rdoc").upload
+ Rake::SshDirPublisher.new("rails@api.rubyonrails.org", "public_html/api", "doc/rdoc").upload
PROJECTS.each do |project|
system %(cd #{project} && #{$0} pdoc)
end
@@ -1,4 +1,5 @@
-require 'rubygems'
+gem 'rdoc', '= 2.2'
+require 'rdoc'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
@@ -53,5 +54,5 @@ end
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
require 'rake/contrib/sshpublisher'
- Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/am", "doc").upload
+ Rake::SshDirPublisher.new("rails@api.rubyonrails.org", "public_html/am", "doc").upload
end
View
@@ -1,5 +1,15 @@
*Rails 3.0.0 [Release Candidate] (unreleased)*
+* Add shallow routes back to the new router [Diego Carrion, Andrew White]
+
+ resources :posts do
+ shallow do
+ resources :comments
+ end
+ end
+
+ You can now use comment_path for /comments/1 instead of post_comment_path for /posts/1/comments/1.
+
* Add support for multi-subdomain session by setting cookie host in session cookie so you can share session between www.example.com, example.com and user.example.com. #4818 [Guillermo Álvarez]
* Removed textilize, textilize_without_paragraph and markdown helpers. [Santiago Pastorino]
View
@@ -1,4 +1,5 @@
-require 'rubygems'
+gem 'rdoc', '= 2.2'
+require 'rdoc'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
@@ -1,4 +1,5 @@
require 'active_support/configurable'
+require 'active_support/descendants_tracker'
require 'active_support/core_ext/module/anonymous'
module AbstractController
@@ -10,6 +11,7 @@ class Base
attr_internal :action_name
include ActiveSupport::Configurable
+ extend ActiveSupport::DescendantsTracker
class << self
attr_reader :abstract
@@ -21,17 +23,6 @@ def abstract!
@abstract = true
end
- def inherited(klass)
- ::AbstractController::Base.descendants << klass.to_s
- super
- end
-
- # A list of all descendants of AbstractController::Base. This is
- # useful for initializers which need to add behavior to all controllers.
- def descendants
- @descendants ||= []
- end
-
# A list of all internal methods for a controller. This finds the first
# abstract superclass of a controller, and gets a list of all public
# instance methods on that abstract class. Public instance methods of
@@ -52,8 +52,7 @@ def build(action, app=nil, &block)
class Metal < AbstractController::Base
abstract!
- # :api: public
- attr_internal :params, :env
+ attr_internal :env
# Returns the last part of the controller's name, underscored, without the ending
# "Controller". For instance, MyApp::MyPostsController would return "my_posts" for
@@ -85,6 +84,14 @@ def initialize(*)
super
end
+ def params
+ @_params ||= request.parameters
+ end
+
+ def params=(val)
+ @_params = val
+ end
+
# Basic implementations for content_type=, location=, and headers are
# provided to reduce the dependency on the RackDelegation module
# in Renderer and Redirector.
@@ -14,10 +14,6 @@ def dispatch(action, request, response = ActionDispatch::Response.new)
super(action, request)
end
- def params
- @_params ||= @_request.parameters
- end
-
def response_body=(body)
response.body = body if response
super
@@ -11,7 +11,7 @@ module ActionController
# polymorphic_url([:admin, @article, @comment])
#
# results in:
- #
+ #
# admin_article_comment_url(@article, @comment)
#
# == Usage within the framework
@@ -166,6 +166,7 @@ def build_named_route_call(records, inflection, options = {})
route << RecordIdentifier.__send__("plural_class_name", record)
route = route.singularize if inflection == :singular
route << "_"
+ route << "index_" if RecordIdentifier.uncountable?(record) && inflection == :plural
end
action_prefix(options) + route + routing_type(options).to_s
@@ -1,7 +1,7 @@
require 'active_support/core_ext/module'
module ActionController
- # The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or
+ # The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or
# Active Resources or pretty much any other model type that has an id. These patterns are then used to try elevate
# the view actions to a higher logical level. Example:
#
@@ -28,7 +28,7 @@ module ActionController
# end
#
# As the example above shows, you can stop caring to a large extent what the actual id of the post is. You just know
- # that one is being assigned and that the subsequent calls in redirect_to and the RJS expect that same naming
+ # that one is being assigned and that the subsequent calls in redirect_to and the RJS expect that same naming
# convention and allows you to write less code if you follow it.
module RecordIdentifier
extend self
@@ -59,7 +59,7 @@ def dom_class(record_or_class, prefix = nil)
# If you need to address multiple instances of the same class in the same view, you can prefix the dom_id:
#
# dom_id(Post.find(45), :edit) # => "edit_post_45"
- def dom_id(record, prefix = nil)
+ def dom_id(record, prefix = nil)
if record_id = record_key_for_dom_id(record)
"#{dom_class(record, prefix)}#{JOIN}#{record_id}"
else
@@ -102,6 +102,14 @@ def singular_class_name(record_or_class)
model_name_from_record_or_class(record_or_class).singular
end
+ # Identifies whether the class name of a record or class is uncountable. Examples:
+ #
+ # uncountable?(Sheep) # => true
+ # uncountable?(Post) => false
+ def uncountable?(record_or_class)
+ plural_class_name(record_or_class) == singular_class_name(record_or_class)
+ end
+
private
def model_name_from_record_or_class(record_or_class)
(record_or_class.is_a?(Class) ? record_or_class : record_or_class.class).model_name
View
No changes.
@@ -8,7 +8,7 @@ module ActionDispatch
class Callbacks
include ActiveSupport::Callbacks
- define_callbacks :call, :terminator => "result == false", :rescuable => true
+ define_callbacks :call, :rescuable => true
define_callbacks :prepare, :scope => :name
# Add a preparation callback. Preparation callbacks are run before every
@@ -37,12 +37,12 @@ def self.after(*args, &block)
def initialize(app, prepare_each_request = false)
@app, @prepare_each_request = app, prepare_each_request
- run_callbacks(:prepare)
+ _run_prepare_callbacks
end
def call(env)
- run_callbacks(:call) do
- run_callbacks(:prepare) if @prepare_each_request
+ _run_call_callbacks do
+ _run_prepare_callbacks if @prepare_each_request
@app.call(env)
end
end
@@ -122,7 +122,7 @@ def status_code(exception)
end
def render(status, body)
- [status, {'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s}, [body]]
+ [status, {'Content-Type' => 'text/html', 'Content-Length' => body.bytesize.to_s}, [body]]
end
def public_path
@@ -10,7 +10,7 @@ class Railtie < Rails::Railtie
# Prepare dispatcher callbacks and run 'prepare' callbacks
initializer "action_dispatch.prepare_dispatcher" do |app|
- ActionDispatch::Callbacks.to_prepare { app.routes_reloader.reload_if_changed }
+ ActionDispatch::Callbacks.to_prepare { app.routes_reloader.execute_if_updated }
end
end
end
Oops, something went wrong.

0 comments on commit 207fa59

Please sign in to comment.