Permalink
Browse files

Merge remote branch 'rails/master' into pg_schema_fu

  • Loading branch information...
2 parents b0d5990 + 6c705e3 commit 2b3d67fdaf2c78a5447316a90c54c7c9c520c71a @tardate committed Jun 19, 2011
Showing with 1,294 additions and 542 deletions.
  1. +5 −2 Gemfile
  2. +3 −3 README.rdoc
  3. +21 −2 Rakefile
  4. +5 −5 actionmailer/lib/action_mailer/base.rb
  5. +28 −21 actionpack/CHANGELOG
  6. +1 −0 actionpack/lib/action_controller/metal/redirecting.rb
  7. +3 −3 actionpack/lib/action_dispatch/http/headers.rb
  8. +11 −1 actionpack/lib/action_dispatch/http/upload.rb
  9. +1 −1 actionpack/lib/action_dispatch/routing.rb
  10. +4 −4 actionpack/lib/action_dispatch/routing/mapper.rb
  11. +1 −1 actionpack/lib/action_view/helpers/controller_helper.rb
  12. +6 −7 actionpack/lib/action_view/helpers/date_helper.rb
  13. +15 −11 actionpack/lib/action_view/helpers/form_helper.rb
  14. +42 −26 actionpack/lib/action_view/helpers/form_options_helper.rb
  15. +7 −4 actionpack/lib/action_view/helpers/form_tag_helper.rb
  16. +3 −3 actionpack/lib/action_view/helpers/text_helper.rb
  17. +1 −1 actionpack/lib/action_view/helpers/translation_helper.rb
  18. +12 −3 actionpack/lib/sprockets/railtie.rb
  19. +1 −1 actionpack/test/abstract/abstract_controller_test.rb
  20. +0 −1 actionpack/test/controller/test_test.rb
  21. +2 −2 actionpack/test/controller/url_for_test.rb
  22. +2 −2 actionpack/test/controller/webservice_test.rb
  23. +7 −0 actionpack/test/dispatch/uploaded_file_test.rb
  24. +2 −2 actionpack/test/template/form_helper_test.rb
  25. +18 −2 actionpack/test/template/form_options_helper_test.rb
  26. +2 −2 actionpack/test/template/form_tag_helper_test.rb
  27. +8 −0 actionpack/test/template/translation_helper_test.rb
  28. +8 −0 actionpack/test/template/url_helper_test.rb
  29. +3 −0 activemodel/CHANGELOG
  30. +1 −1 activemodel/lib/active_model/mass_assignment_security/sanitizer.rb
  31. +3 −4 activemodel/lib/active_model/naming.rb
  32. +2 −3 activemodel/lib/active_model/translation.rb
  33. +0 −1 activemodel/test/cases/attribute_methods_test.rb
  34. +0 −10 activemodel/test/cases/translation_test.rb
  35. +5 −0 activerecord/RUNNING_UNIT_TESTS
  36. +43 −24 activerecord/lib/active_record/associations/collection_association.rb
  37. +10 −11 activerecord/lib/active_record/base.rb
  38. +1 −0 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  39. +5 −5 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  40. +4 −4 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  41. +1 −1 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
  42. +2 −2 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  43. +4 −2 activerecord/lib/active_record/migration.rb
  44. +19 −13 activerecord/lib/active_record/nested_attributes.rb
  45. +10 −7 activerecord/lib/active_record/test_case.rb
  46. +63 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  47. +1 −1 activerecord/test/cases/autosave_association_test.rb
  48. +7 −6 activerecord/test/cases/helper.rb
  49. +275 −30 activerecord/test/cases/mass_assignment_security_test.rb
  50. +12 −0 activerecord/test/models/company.rb
  51. +6 −2 activerecord/test/models/person.rb
  52. +8 −4 activerecord/test/support/config.rb
  53. +7 −1 activesupport/CHANGELOG
  54. +1 −1 activesupport/lib/active_support/core_ext/array/wrap.rb
  55. +3 −2 activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
  56. +1 −1 activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
  57. +37 −12 activesupport/lib/active_support/core_ext/string/output_safety.rb
  58. +26 −1 activesupport/lib/active_support/core_ext/time/calculations.rb
  59. +0 −11 activesupport/lib/active_support/dependencies.rb
  60. +12 −1 activesupport/lib/active_support/memoizable.rb
  61. +9 −2 activesupport/test/core_ext/class/attribute_accessor_test.rb
  62. +7 −1 activesupport/test/core_ext/string_ext_test.rb
  63. +20 −0 activesupport/test/core_ext/time_ext_test.rb
  64. +3 −1 activesupport/test/flush_cache_on_private_memoization_test.rb
  65. +32 −6 activesupport/test/memoizable_test.rb
  66. +37 −5 activesupport/test/safe_buffer_test.rb
  67. +2 −0 railties/CHANGELOG
  68. +3 −3 railties/guides/source/action_view_overview.textile
  69. +5 −5 railties/guides/source/active_record_validations_callbacks.textile
  70. +60 −10 railties/guides/source/active_support_core_extensions.textile
  71. +72 −20 railties/guides/source/asset_pipeline.textile
  72. +1 −0 railties/guides/source/caching_with_rails.textile
  73. +74 −116 railties/guides/source/command_line.textile
  74. +30 −15 railties/guides/source/configuring.textile
  75. +2 −2 railties/guides/source/contributing_to_ruby_on_rails.textile
  76. +40 −5 railties/guides/source/getting_started.textile
  77. +6 −6 railties/guides/source/nested_model_forms.textile
  78. +3 −3 railties/guides/source/performance_testing.textile
  79. +4 −6 railties/guides/source/rails_application_templates.textile
  80. +0 −6 railties/lib/rails/application.rb
  81. +1 −1 railties/lib/rails/application/railties.rb
  82. +2 −2 railties/lib/rails/commands/plugin.rb
  83. +10 −2 railties/lib/rails/engine.rb
  84. +12 −6 railties/lib/rails/generators/app_base.rb
  85. +1 −1 railties/lib/rails/generators/generated_attribute.rb
  86. +0 −3 railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
  87. +1 −1 railties/lib/rails/generators/rails/app/templates/config/routes.rb
  88. +7 −7 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
  89. +14 −0 railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/application.html.erb.tt
  90. +4 −4 railties/lib/rails/railtie.rb
  91. +3 −3 railties/test/application/initializers/i18n_test.rb
  92. +3 −10 railties/test/generators/generated_attribute_test.rb
  93. +9 −3 railties/test/generators/model_generator_test.rb
  94. +17 −13 railties/test/generators/plugin_new_generator_test.rb
  95. +9 −3 railties/test/generators/scaffold_generator_test.rb
View
@@ -26,6 +26,9 @@ gem "memcache-client", ">= 1.8.5"
platforms :mri_18 do
gem "system_timer"
+ # ruby-debug requires linecache which depends on require_relative but doesn't explicitly
+ # declare this in its gemspec
+ gem "require_relative"
gem "ruby-debug", ">= 0.10.3"
gem "json"
end
@@ -41,7 +44,7 @@ platforms :ruby do
end
gem "json"
gem "yajl-ruby"
- gem "nokogiri", ">= 1.4.4"
+ gem "nokogiri", ">= 1.4.5"
group :test do
gem "ruby-prof" if RUBY_VERSION < "1.9.3"
@@ -53,7 +56,7 @@ platforms :ruby do
group :db do
gem "pg", ">= 0.11.0"
gem "mysql", ">= 2.8.1"
- gem "mysql2", ">= 0.3.0"
+ gem "mysql2", ">= 0.3.6"
end
end
View
@@ -1,7 +1,7 @@
== Welcome to Rails
Rails is a web-application framework that includes everything needed to create
-database-backed web applications according to the Model-View-Controller pattern.
+database-backed web applications according to the {Model-View-Controller (MVC)}[http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller] pattern.
Understanding the MVC pattern is key to understanding Rails. MVC divides your application
into three layers, each with a specific responsibility.
@@ -18,7 +18,7 @@ you to present the data from database rows as objects and embellish these data o
with business logic methods. Although most Rails models are backed by a database, models
can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as
provided by the ActiveModel module. You can read more about Active Record in its
-{README}[link:files/activerecord/README_rdoc.html].
+{README}[link:blob/master/activerecord/README.rdoc].
The Controller layer is responsible for handling incoming HTTP requests and providing a
suitable response. Usually this means returning HTML, but Rails controllers can also
@@ -29,7 +29,7 @@ In Rails, the Controller and View layers are handled together by Action Pack.
These two layers are bundled in a single package due to their heavy interdependence.
This is unlike the relationship between the Active Record and Action Pack which are
independent. Each of these packages can be used independently outside of Rails. You
-can read more about Action Pack in its {README}[link:files/actionpack/README_rdoc.html].
+can read more about Action Pack in its {README}[link:blob/master/actionpack/README.rdoc].
== Getting Started
View
@@ -51,9 +51,28 @@ desc "Generate documentation for the Rails framework"
RDoc::Task.new do |rdoc|
RDOC_MAIN = 'RDOC_MAIN.rdoc'
+ # This is a hack.
+ #
+ # Backslashes are needed to prevent RDoc from autolinking "Rails" to the
+ # documentation of the Rails module. On the other hand, as of this
+ # writing README.rdoc is displayed in the front page of the project in
+ # GitHub, where backslashes are shown and look weird.
+ #
+ # The temporary solution is to have a README.rdoc without backslashes for
+ # GitHub, and gsub it to generate the main page of the API.
+ #
+ # The idea for the future is to have totally different files, since the
+ # API is no longer a generic entry point to Rails and deserves a
+ # dedicated main page specifically thought as an API entry point.
rdoc.before_running_rdoc do
rdoc_main = File.read('README.rdoc')
- rdoc_main.gsub!(/\b(?=Rails)\b/) { '\\' }
+
+ # The ^(?=\S) assertion prevents code blocks from being processed,
+ # since no autolinking happens there and RDoc displays the backslash
+ # otherwise.
+ rdoc_main.gsub!(/^(?=\S).*?\b(?=Rails)\b/) { "#$&\\" }
+ rdoc_main.gsub!(/link:blob\/master\/(\w+)\/README.rdoc/, "link:files/\\1/README_rdoc.html")
+
File.open(RDOC_MAIN, 'w') do |f|
f.write(rdoc_main)
end
@@ -72,7 +91,7 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include('railties/MIT-LICENSE')
rdoc.rdoc_files.include('railties/README.rdoc')
rdoc.rdoc_files.include('railties/lib/**/*.rb')
- rdoc.rdoc_files.exclude('railties/lib/rails/generators/**/templates/*')
+ rdoc.rdoc_files.exclude('railties/lib/rails/generators/**/templates/**/*.rb')
rdoc.rdoc_files.include('activerecord/README.rdoc')
rdoc.rdoc_files.include('activerecord/CHANGELOG')
@@ -57,7 +57,7 @@ module ActionMailer #:nodoc:
# will accept (any valid Email header including optional fields).
#
# The mail method, if not passed a block, will inspect your views and send all the views with
- # the same name as the method, so the above action would send the +welcome.text.plain.erb+ view
+ # the same name as the method, so the above action would send the +welcome.text.erb+ view
# file as well as the +welcome.text.html.erb+ view file in a +multipart/alternative+ email.
#
# If you want to explicitly render only certain templates, pass a block:
@@ -88,7 +88,7 @@ module ActionMailer #:nodoc:
#
# To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same
# name as the method in your mailer model. For example, in the mailer defined above, the template at
- # <tt>app/views/notifier/signup_notification.text.plain.erb</tt> would be used to generate the email.
+ # <tt>app/views/notifier/welcome.text.erb</tt> would be used to generate the email.
#
# Variables defined in the model are accessible as instance variables in the view.
#
@@ -153,7 +153,7 @@ module ActionMailer #:nodoc:
# by the content type. Each such detected template will be added as separate part to the message.
#
# For example, if the following templates exist:
- # * signup_notification.text.plain.erb
+ # * signup_notification.text.erb
# * signup_notification.text.html.erb
# * signup_notification.text.xml.builder
# * signup_notification.text.yaml.erb
@@ -178,7 +178,7 @@ module ActionMailer #:nodoc:
# end
# end
#
- # Which will (if it had both a <tt>welcome.text.plain.erb</tt> and <tt>welcome.text.html.erb</tt>
+ # Which will (if it had both a <tt>welcome.text.erb</tt> and <tt>welcome.text.html.erb</tt>
# template in the view directory), send a complete <tt>multipart/mixed</tt> email with two parts,
# the first part being a <tt>multipart/alternative</tt> with the text and HTML email parts inside,
# and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book
@@ -365,7 +365,7 @@ def register_observer(observer)
Mail.register_observer(delivery_observer)
end
- # Register an Inteceptor which will be called before mail is sent.
+ # Register an Interceptor which will be called before mail is sent.
# Either a class or a string can be passed in as the Interceptor. If a string is passed in
# it will be <tt>constantize</tt>d.
def register_interceptor(interceptor)
View
@@ -1,5 +1,33 @@
*Rails 3.2.0 (unreleased)*
+* Generate hidden input before select with :multiple option set to true.
+ This is useful when you rely on the fact that when no options is set,
+ the state of select will be sent to rails application. Without hidden field
+ nothing is sent according to HTML spec [Bogdan Gusiev]
+
+* Refactor ActionController::TestCase cookies [Andrew White]
+
+ Assigning cookies for test cases should now use cookies[], e.g:
+
+ cookies[:email] = 'user@example.com'
+ get :index
+ assert_equal 'user@example.com', cookies[:email]
+
+ To clear the cookies, use clear, e.g:
+
+ cookies.clear
+ get :index
+ assert_nil cookies[:email]
+
+ We now no longer write out HTTP_COOKIE and the cookie jar is
+ persistent between requests so if you need to manipulate the environment
+ for your test you need to do it before the cookie jar is created.
+
+
+*Rails 3.1.0 (unreleased)*
+
+* json_escape will now return a SafeBuffer string if it receives SafeBuffer string [tenderlove]
+
* Make sure escape_js returns SafeBuffer string if it receives SafeBuffer string [Prem Sichanugrist]
* Fix escape_js to work correctly with the new SafeBuffer restriction [Paul Gallagher]
@@ -31,27 +59,6 @@
You can read more about this change in http://groups.google.com/group/rubyonrails-security/browse_thread/thread/2e516e7acc96c4fb
-* Refactor ActionController::TestCase cookies [Andrew White]
-
- Assigning cookies for test cases should now use cookies[], e.g:
-
- cookies[:email] = 'user@example.com'
- get :index
- assert_equal 'user@example.com', cookies[:email]
-
- To clear the cookies, use clear, e.g:
-
- cookies.clear
- get :index
- assert_nil cookies[:email]
-
- We now no longer write out HTTP_COOKIE and the cookie jar is
- persistent between requests so if you need to manipulate the environment
- for your test you need to do it before the cookie jar is created.
-
-
-*Rails 3.1.0 (unreleased)*
-
* Added 'ActionView::Helpers::FormHelper.fields_for_with_index', similar to fields_for but allows to have access to the current iteration index [Jorge Bejar]
* Warn if we cannot verify CSRF token authenticity [José Valim]
@@ -43,6 +43,7 @@ module Redirecting
#
# The status code can either be a standard {HTTP Status code}[http://www.iana.org/assignments/http-status-codes] as an
# integer, or a symbol representing the downcased, underscored and symbolized description.
+ # Note that the status code must be a 3xx HTTP code, or redirection will not occur.
#
# It is also possible to assign a flash message as part of the redirection. There are two special accessors for commonly used the flash names
# +alert+ and +notice+ as well as a general purpose +flash+ bucket.
@@ -3,9 +3,10 @@
module ActionDispatch
module Http
class Headers < ::Hash
- extend ActiveSupport::Memoizable
+ @@env_cache = Hash.new { |h,k| h[k] = "HTTP_#{k.upcase.gsub(/-/, '_')}" }
def initialize(*args)
+
if args.size == 1 && args[0].is_a?(Hash)
super()
update(args[0])
@@ -25,9 +26,8 @@ def [](header_name)
private
# Converts a HTTP header name to an environment variable name.
def env_name(header_name)
- "HTTP_#{header_name.upcase.gsub(/-/, '_')}"
+ @@env_cache[header_name]
end
- memoize :env_name
end
end
end
@@ -4,7 +4,7 @@ class UploadedFile
attr_accessor :original_filename, :content_type, :tempfile, :headers
def initialize(hash)
- @original_filename = hash[:filename]
+ @original_filename = encode_filename(hash[:filename])
@content_type = hash[:type]
@headers = hash[:head]
@tempfile = hash[:tempfile]
@@ -30,6 +30,16 @@ def rewind
def size
@tempfile.size
end
+
+ private
+ def encode_filename(filename)
+ # Encode the filename in the utf8 encoding, unless it is nil or we're in 1.8
+ if "ruby".encoding_aware? && filename
+ filename.force_encoding("UTF-8").encode!
+ else
+ filename
+ end
+ end
end
module Upload
@@ -161,7 +161,7 @@ module ActionDispatch
# Consider the following route, which you will find commented out at the
# bottom of your generated <tt>config/routes.rb</tt>:
#
- # match ':controller(/:action(/:id(.:format)))'
+ # match ':controller(/:action(/:id))(.:format)'
#
# This route states that it expects requests to consist of a
# <tt>:controller</tt> followed optionally by an <tt>:action</tt> that in
@@ -87,7 +87,7 @@ def normalize_options!
raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
end
end
- end
+ end
# match "account/overview"
def using_match_shorthand?(path, options)
@@ -1105,9 +1105,9 @@ def resource(*resources, &block)
#
# The +comments+ resource here will have the following routes generated for it:
#
- # post_comments GET /sekret/posts/:post_id/comments(.:format)
- # post_comments POST /sekret/posts/:post_id/comments(.:format)
- # new_post_comment GET /sekret/posts/:post_id/comments/new(.:format)
+ # post_comments GET /posts/:post_id/comments(.:format)
+ # post_comments POST /posts/:post_id/comments(.:format)
+ # new_post_comment GET /posts/:post_id/comments/new(.:format)
# edit_comment GET /sekret/comments/:id/edit(.:format)
# comment GET /sekret/comments/:id(.:format)
# comment PUT /sekret/comments/:id(.:format)
@@ -20,4 +20,4 @@ def assign_controller(controller)
end
end
end
-end
+end
@@ -621,7 +621,6 @@ def time_tag(date_or_time, *args)
end
class DateTimeSelector #:nodoc:
- extend ActiveSupport::Memoizable
include ActionView::Helpers::TagHelper
DEFAULT_PREFIX = 'date'.freeze
@@ -786,11 +785,12 @@ def select_year
# Returns translated month names, but also ensures that a custom month
# name array has a leading nil element.
def month_names
- month_names = @options[:use_month_names] || translated_month_names
- month_names.unshift(nil) if month_names.size < 13
- month_names
+ @month_names ||= begin
+ month_names = @options[:use_month_names] || translated_month_names
+ month_names.unshift(nil) if month_names.size < 13
+ month_names
+ end
end
- memoize :month_names
# Returns translated month names.
# => [nil, "January", "February", "March",
@@ -825,9 +825,8 @@ def month_name(number)
end
def date_order
- @options[:order] || translated_date_order
+ @date_order ||= @options[:order] || translated_date_order
end
- memoize :date_order
def translated_date_order
I18n.translate(:'date.order', :locale => @options[:locale]) || []
@@ -219,9 +219,9 @@ def convert_to_model(object)
# <% end %>
#
# If you have an object that needs to be represented as a different
- # parameter, like a Client that acts as a Person:
+ # parameter, like a Person that acts as a Client:
#
- # <%= form_for(@post, :as => :client) do |f| %>
+ # <%= form_for(@person, :as => :client) do |f| %>
# ...
# <% end %>
#
@@ -290,7 +290,7 @@ def convert_to_model(object)
#
# Example:
#
- # <%= form(@post) do |f| %>
+ # <%= form_for(@post) do |f| %>
# <% f.fields_for(:comments, :include_id => false) do |cf| %>
# ...
# <% end %>
@@ -517,6 +517,18 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
# end
# end
#
+ # Note that the <tt>projects_attributes=</tt> writer method is in fact
+ # required for fields_for to correctly identify <tt>:projects</tt> as a
+ # collection, and the correct indices to be set in the form markup.
+ #
+ # When projects is already an association on Person you can use
+ # +accepts_nested_attributes_for+ to define the writer method for you:
+ #
+ # class Person < ActiveRecord::Base
+ # has_many :projects
+ # accepts_nested_attributes_for :projects
+ # end
+ #
# This model can now be used with a nested fields_for. The block given to
# the nested fields_for call will be repeated for each instance in the
# collection:
@@ -568,14 +580,6 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
# ...
# <% end %>
#
- # When projects is already an association on Person you can use
- # +accepts_nested_attributes_for+ to define the writer method for you:
- #
- # class Person < ActiveRecord::Base
- # has_many :projects
- # accepts_nested_attributes_for :projects
- # end
- #
# If you want to destroy any of the associated models through the
# form, you have to enable it first using the <tt>:allow_destroy</tt>
# option for +accepts_nested_attributes_for+:
Oops, something went wrong.

0 comments on commit 2b3d67f

Please sign in to comment.