From 3859828d89d378986af0fc2390608b00aad5e912 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 31 Mar 2010 19:49:29 -0700 Subject: HTML safety: give a deprecation warning if an array of option tags is passed to select tag. Be sure to join the tag yourself and mark them .html_safe --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 4 ++++ actionpack/test/template/form_tag_helper_test.rb | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index ca100e102e..0d47c6eecb 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -93,6 +93,10 @@ module ActionView # # => def select_tag(name, option_tags = nil, options = {}) + if Array === option_tags + ActiveSupport::Deprecation.warn 'Passing an array of option_tags to select_tag implicitly joins them without marking them as HTML-safe. Pass option_tags.join.html_safe instead.', caller + end + html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name if blank = options.delete(:include_blank) if blank.kind_of?(String) diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 868a35c476..1f26840289 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -158,6 +158,12 @@ class FormTagHelperTest < ActionView::TestCase assert_dom_equal expected, actual end + def test_select_tag_with_array_options + assert_deprecated /array/ do + select_tag "people", [""] + end + end + def test_text_area_tag_size_string actual = text_area_tag "body", "hello world", "size" => "20x40" expected = %() -- cgit v1.2.3 From 81e69332466003732846bd7dbc04e8550bfe16a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20de=20P=C3=A1dua?= Date: Thu, 1 Apr 2010 01:19:09 -0300 Subject: Fix error in number_with_precision with :significant option and zero value [#4306 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/lib/action_view/helpers/number_helper.rb | 8 ++++++-- actionpack/test/template/number_helper_test.rb | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 605e5d5873..01fecc0f23 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -273,8 +273,12 @@ module ActionView strip_insignificant_zeros = options.delete :strip_insignificant_zeros if significant and precision > 0 - digits = (Math.log10(number) + 1).floor - rounded_number = BigDecimal.new((number / 10 ** (digits - precision)).to_s).round.to_f * 10 ** (digits - precision) + if number == 0 + digits, rounded_number = 1, 0 + else + digits = (Math.log10(number) + 1).floor + rounded_number = BigDecimal.new((number / 10 ** (digits - precision)).to_s).round.to_f * 10 ** (digits - precision) + end precision = precision - digits precision = precision > 0 ? precision : 0 #don't let it be negative else diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb index 50c57a5588..a21a1a68e4 100644 --- a/actionpack/test/template/number_helper_test.rb +++ b/actionpack/test/template/number_helper_test.rb @@ -102,6 +102,9 @@ class NumberHelperTest < ActionView::TestCase assert_equal("3268", number_with_precision((32.6751 * 100.00), :precision => 0)) assert_equal("112", number_with_precision(111.50, :precision => 0)) assert_equal("1234567892", number_with_precision(1234567891.50, :precision => 0)) + assert_equal("0", number_with_precision(0, :precision => 0)) + assert_equal("0.00100", number_with_precision(0.001, :precision => 5)) + assert_equal("0.001", number_with_precision(0.00111, :precision => 3)) end def test_number_with_precision_with_custom_delimiter_and_separator @@ -122,11 +125,17 @@ class NumberHelperTest < ActionView::TestCase assert_equal "53", number_with_precision(52.7923, :precision => 2, :significant => true ) assert_equal "9775.00", number_with_precision(9775, :precision => 6, :significant => true ) assert_equal "5.392900", number_with_precision(5.3929, :precision => 7, :significant => true ) + assert_equal "0.0", number_with_precision(0, :precision => 2, :significant => true ) + assert_equal "0", number_with_precision(0, :precision => 1, :significant => true ) + assert_equal "0.0001", number_with_precision(0.0001, :precision => 1, :significant => true ) + assert_equal "0.000100", number_with_precision(0.0001, :precision => 3, :significant => true ) + assert_equal "0.0001", number_with_precision(0.0001111, :precision => 1, :significant => true ) end def test_number_with_precision_with_strip_insignificant_zeros assert_equal "9775.43", number_with_precision(9775.43, :precision => 4, :strip_insignificant_zeros => true ) assert_equal "9775.2", number_with_precision(9775.2, :precision => 6, :significant => true, :strip_insignificant_zeros => true ) + assert_equal "0", number_with_precision(0, :precision => 6, :significant => true, :strip_insignificant_zeros => true ) end def test_number_with_precision_with_significant_true_and_zero_precision -- cgit v1.2.3 From d868cb4f8a84b6275b6407b20bb3ba939a53681a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 1 Apr 2010 13:36:45 -0700 Subject: Prep for beta2, depend on latest Bundler --- actionpack/lib/action_pack/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_pack/version.rb b/actionpack/lib/action_pack/version.rb index 72a1cd30ad..0b40465a79 100644 --- a/actionpack/lib/action_pack/version.rb +++ b/actionpack/lib/action_pack/version.rb @@ -3,7 +3,7 @@ module ActionPack MAJOR = 3 MINOR = 0 TINY = 0 - BUILD = "beta1" + BUILD = "beta2" STRING = [MAJOR, MINOR, TINY, BUILD].join('.') end -- cgit v1.2.3 From d2a48852a197190ecead6650aa62c7df4c3136ee Mon Sep 17 00:00:00 2001 From: wycats Date: Thu, 1 Apr 2010 13:54:53 -0700 Subject: Updated changelogs --- actionpack/CHANGELOG | 546 +++++++++++++++++++++++++++------------------------ 1 file changed, 287 insertions(+), 259 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 014a501080..f6e9bd0d02 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,33 @@ *Edge* +* #concat is now deprecated in favor of using <%= %> helpers [YK] + +* Block helpers now return Strings, so you can use <%= form_for @foo do |f| %>. + <% form_for do |f| %> still works with deprecation notices [YK] + +* Add a new #mount method on the router that does not anchor the PATH_INFO + at the end [YK & CL] + +* Create a new LookupContext object that is responsible for performantly + finding a template for a given pattern [JV] + +* Removed relative_url_for in favor of respecting SCRIPT_NAME [YK & CL] + +* Changed file streaming to use Rack::Sendfile middleware [YK] + +* ActionDispatch::Request#content_type returns a String to be compatible with + Rack::Request. Use #content_mime_type for the Mime::Type instance [YK] + +* Updated Prototype to 1.6.1 and Scriptaculous to 1.8.3 [ML] + +* Change the preferred way that URL helpers are included into a class[YK & CL] + + # for all helpers including named routes + include Rails.application.router.url_helpers + + # for just url_for + include Rails.application.router.url_for + * Fixed that PrototypeHelper#update_page should return html_safe [DHH] * Fixed that much of DateHelper wouldn't return html_safe? strings [DHH] @@ -14,9 +42,9 @@ flash[:notice] = 'Post was created' redirect_to(@post) - + ...becomes: - + redirect_to(@post, :notice => 'Post was created') * Added ActionController::Base#notice/= and ActionController::Base#alert/= as a convenience accessors in both the controller and the view for flash[:notice]/= and flash[:alert]/= [DHH] @@ -147,14 +175,14 @@ # Instead of <%= render :partial => "account" %> <%= render "account" %> - + # Instead of <%= render :partial => "account", :locals => { :account => @buyer } %> <%= render "account", :account => @buyer %> - + # @account is an Account instance, so it uses the RecordIdentifier to replace # <%= render :partial => "accounts/account", :locals => { :account => @account } %> <%= render(@account) %> - + # @posts is an array of Post instances, so it uses the RecordIdentifier to replace # <%= render :partial => "posts/post", :collection => @posts %> <%= render(@posts) %> @@ -245,7 +273,7 @@ * Make PrototypeHelper#submit_to_remote a wrapper around PrototypeHelper#button_to_remote. [Tarmo Tänav] -* Set HttpOnly for the cookie session store's cookie. #1046 +* Set HttpOnly for the cookie session store's cookie. #1046 * Added FormTagHelper#image_submit_tag confirm option #784 [Alastair Brunton] @@ -262,7 +290,7 @@ Completed in 0.10000 (4 reqs/sec) | Rendering: 0.04000 (40%) | DB: 0.00400 (4%) | 200 OK [http://example.com] ...to: - + Completed in 100ms (View: 40, DB: 4) | 200 OK [http://example.com] * Add support for shallow nesting of routes. #838 [S. Brent Faulkner] @@ -347,7 +375,7 @@ * Deprecated TemplateHandler line offset [Josh Peek] * Allow caches_action to accept cache store options. #416. [José Valim]. Example: - + caches_action :index, :redirected, :if => Proc.new { |c| !c.request.format.json? }, :expires_in => 1.hour * Remove define_javascript_functions, javascript_include_tag and friends are far superior. [Michael Koziarski] @@ -357,7 +385,7 @@ * Add :as option to render a collection of partials with a custom local variable name. #509 [Simon Jefford, Pratik Naik] render :partial => 'other_people', :collection => @people, :as => :person - + This will let you access objects of @people as 'person' local variable inside 'other_people' partial template. * time_zone_select: support for regexp matching of priority zones. Resolves #195 [Ernie Miller] @@ -511,7 +539,7 @@ * Remove support for multivalued (e.g., '&'-delimited) cookies. [Jamis Buck] -* Fix problem with render :partial collections, records, and locals. #11057 [lotswholetime] +* Fix problem with render :partial collections, records, and locals. #11057 [lotswholetime] * Added support for naming concrete classes in sweeper declarations [David Heinemeier Hansson] @@ -534,7 +562,7 @@ * Make assert_routing aware of the HTTP method used. #8039 [mpalmer] e.g. assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" }) -* Make map.root accept a single symbol as an argument to declare an alias. #10818 [bscofield] +* Make map.root accept a single symbol as an argument to declare an alias. #10818 [bscofield] e.g. map.dashboard '/dashboard', :controller=>'dashboard' map.root :dashboard @@ -543,7 +571,7 @@ * Add label_tag helper for generating elements. #10802 [DefV] -* Introduce TemplateFinder to handle view paths and lookups. #10800 [Pratik Naik] +* Introduce TemplateFinder to handle view paths and lookups. #10800 [Pratik Naik] * Performance: optimize route recognition. Large speedup for apps with many resource routes. #10835 [oleganza] @@ -768,7 +796,7 @@ * ActionController::Routing::DynamicSegment#interpolation_chunk should call #to_s on all values before calling URI.escape. [Rick Olson] -* Only accept session ids from cookies, prevents session fixation attacks. [bradediger] +* Only accept session ids from cookies, prevents session fixation attacks. [bradediger] *2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.12.2 - 1.13.3] @@ -827,7 +855,7 @@ def index @posts = Post.find(:all) - + respond_to do |format| format.html # => renders index.html.erb and uses "text/html" as the content type format.iphone # => renders index.iphone.erb and uses "text/html" as the content type @@ -921,7 +949,7 @@ After filters will *no longer* be run if an around_filter fails to yield, users relying on this behaviour are advised to put the code in question after a yield statement in an around filter. - + * Allow you to delete cookies with options. Closes #3685 [Josh Peek, Chris Wanstrath] @@ -1021,13 +1049,13 @@ * Update to Prototype 1.5.1. [Sam Stephenson] -* Allow routes to be decalred under namespaces [Tobias Lütke]: - +* Allow routes to be decalred under namespaces [Tobias Lütke]: + map.namespace :admin do |admin| - admin.root :controller => "products" + admin.root :controller => "products" admin.feed 'feed.xml', :controller => 'products', :action => 'feed', :format => 'xml' end - + * Update to script.aculo.us 1.7.1_beta3. [Thomas Fuchs] * observe_form always sends the serialized form. #5271 [Manfred Stienstra, normelton@gmail.com] @@ -1039,7 +1067,7 @@ * Added url_for usage on render :location, which allows for record identification [David Heinemeier Hansson]. Example: render :xml => person, :status => :created, :location => person - + ...expands the location to person_url(person). * Introduce the request.body stream. Lazy-read to parse parameters rather than always setting RAW_POST_DATA. Reduces the memory footprint of large binary PUT requests. [Jeremy Kemper] @@ -1067,21 +1095,21 @@ <% form_for(@post) do |f| %> ... <% end %> - + This will expand to be the same as: - + <% form_for :post, @post, :url => post_path(@post), :html => { :method => :put, :class => "edit_post", :id => "edit_post_45" } do |f| %> ... <% end %> - + And for new records: - + <% form_for(Post.new) do |f| %> ... <% end %> - + This will expand to be the same as: - + <% form_for :post, @post, :url => posts_path, :html => { :class => "new_post", :id => "new_post" } do |f| %> ... <% end %> @@ -1093,7 +1121,7 @@ redirect_to(post) # => redirect_to(posts_url(post)) => Location: http://example.com/posts/1 link_to(post.title, post) # => link_to(post.title, posts_url(post)) => Hello world - Any method that calls url_for on its parameters will automatically benefit from this. + Any method that calls url_for on its parameters will automatically benefit from this. * Removed deprecated parameters_for_method_reference concept (legacy from before named routes) [David Heinemeier Hansson] @@ -1137,14 +1165,14 @@ * Added map.namespace to deal with the common situation of admin sections and the like [David Heinemeier Hansson] Before: - + map.resources :products, :path_prefix => "admin", :controller => "admin/products", :collection => { :inventory => :get }, :member => { :duplicate => :post } map.resources :tags, :name_prefix => 'admin_product_', :path_prefix => "admin/products/:product_id", :controller => "admin/product_tags" map.resources :images, :name_prefix => 'admin_product_', :path_prefix => "admin/products/:product_id", :controller => "admin/product_images" map.resources :variants, :name_prefix => 'admin_product_', :path_prefix => "admin/products/:product_id", :controller => "admin/product_variants" After: - + map.namespace(:admin) do |admin| admin.resources :products, :collection => { :inventory => :get }, @@ -1160,28 +1188,28 @@ emails.resources :comments, :name_prefix => "email_" emails.resources :attachments, :name_prefix => "email_" end - + After: map.resources :emails do |emails| emails.resources :comments emails.resources :attachments end - + This does mean that if you intended to have comments_url go to /emails/5/comments, then you'll have to set :name_prefix to nil explicitly. * Added :has_many and :has_one for declaring plural and singular resources beneath the current [David Heinemeier Hansson] Before: - + map.resources :notes do |notes| notes.resources :comments notes.resources :attachments notes.resource :author end - + After: - + map.resources :notes, :has_many => [ :comments, :attachments ], :has_one => :author * Added that render :xml will try to call to_xml if it can [David Heinemeier Hansson]. Makes these work: @@ -1209,9 +1237,9 @@ * Default xml template goes from #{action_name}.rxml => #{action_name}.xml.builder. * Default rjs template goes from #{action_name}.rjs => #{action_name}.js.rjs. - + You can still specify your old templates: - + respond_to do |format| format.xml do render :action => "#{action_name}.rxml" @@ -1239,8 +1267,8 @@ * Allow configuration of the default action cache path for #caches_action calls. [Rick Olson] class ListsController < ApplicationController - caches_action :index, :cache_path => Proc.new { |controller| - controller.params[:user_id] ? + caches_action :index, :cache_path => Proc.new { |controller| + controller.params[:user_id] ? controller.send(:user_lists_url, c.params[:user_id]) : controller.send(:lists_url) } end @@ -1313,7 +1341,7 @@ Roos] - + stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is true => @@ -1469,7 +1497,7 @@ superclass' view_paths. [Rick Olson] * Add singleton resources. [Rick Olson] map.resource :account - + GET /account GET /account;edit UPDATE /account @@ -1508,7 +1536,7 @@ superclass' view_paths. [Rick Olson] * Added the option for extension aliases to mime type registration [David Heinemeier Hansson]. Example (already in the default routes): Mime::Type.register "text/html", :html, %w( application/xhtml+xml ), %w( xhtml ) - + ...will respond on both .html and .xhtml. * @response.redirect_url works with 201 Created responses: just return headers['Location'] rather than checking the response status. [Jeremy Kemper] @@ -1577,7 +1605,7 @@ superclass' view_paths. [Rick Olson] <% content_tag :div, :class => "strong" %> Hello world! <% end %> - + Will output:
Hello world!
@@ -1636,7 +1664,7 @@ superclass' view_paths. [Rick Olson] Gives: - + Which is needed for dealing with the IE6 DOM when it's not yet fully loaded. * Fixed that rescue template path shouldn't be hardcoded, then it's easier to hook in your own #6295 [Mike Naberezny] @@ -1693,9 +1721,9 @@ superclass' view_paths. [Rick Olson] * Added proper getters and setters for content type and charset [David Heinemeier Hansson]. Example of what we used to do: response.headers["Content-Type"] = "application/atom+xml; charset=utf-8" - + ...now: - + response.content_type = Mime::ATOM response.charset = "utf-8" @@ -1738,7 +1766,7 @@ superclass' view_paths. [Rick Olson] * Fixed JavaScriptHelper#link_to_function and JavaScriptHelper#button_to_function to have the script argument be optional [David Heinemeier Hansson]. So what used to require a nil, like this: link_to("Hider", nil, :class => "hider_link") { |p| p[:something].hide } - + ...can be written like this: link_to("Hider", :class => "hider_link") { |p| p[:something].hide } @@ -1756,7 +1784,7 @@ superclass' view_paths. [Rick Olson] * Fixed that AssetTagHelper#image_tag and others using compute_public_path should not modify the incoming source argument (closes #5102) [eule@space.ch] -* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] +* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] * Fixed FormOptionsHelper#select to respect :selected value #5813 @@ -1953,7 +1981,7 @@ superclass' view_paths. [Rick Olson] class WeblogController < ActionController::Base def index @posts = Post.find :all - + respond_to do |format| format.html format.xml { render :xml => @posts.to_xml } @@ -1961,26 +1989,26 @@ superclass' view_paths. [Rick Olson] end end end - + # returns HTML when requested by a browser, since the browser # has the HTML mimetype at the top of its priority list Accept: text/html - GET /weblog - - # returns the XML + GET /weblog + + # returns the XML Accept: application/xml - GET /weblog + GET /weblog - # returns the HTML + # returns the HTML Accept: application/xml GET /weblog.html # returns the XML Accept: text/html GET /weblog.xml - + All this relies on the fact that you have a route that includes .:format. - + * Expanded :method option in FormTagHelper#form_tag, FormHelper#form_for, PrototypeHelper#remote_form_for, PrototypeHelper#remote_form_tag, and PrototypeHelper#link_to_remote to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [David Heinemeier Hansson] * Added :method option to UrlHelper#link_to, which allows for using other verbs than GET for the link. This replaces the :post option, which is now deprecated. Example: link_to "Destroy", person_url(:id => person), :method => :delete [David Heinemeier Hansson] @@ -2016,12 +2044,12 @@ superclass' view_paths. [Rick Olson] * Fixes bad rendering of JavaScriptMacrosHelper rdoc (closes #4910) [Frederick Ros] * Allow error_messages_for to report errors for multiple objects, as well as support for customizing the name of the object in the error summary header. Closes #4186. [andrew@redlinesoftware.com, Marcel Molina Jr.] - + error_messages_for :account, :user, :subscription, :object_name => :account * Enhance documentation for setting headers in integration tests. Skip auto HTTP prepending when its already there. Closes #4079. [Rick Olson] -* Documentation for AbstractRequest. Closes #4895. [Kevin Clark] +* Documentation for AbstractRequest. Closes #4895. [Kevin Clark] * Refactor various InstanceTag instance method to class methods. Closes #4800. [Stefan Kaes] @@ -2054,8 +2082,8 @@ superclass' view_paths. [Rick Olson] * Modify routing so that you can say :require => { :method => :post } for a route, and the route will never be selected unless the request method is POST. Only works for route recognition, not for route generation. [Jamis Buck] * Added :add_headers option to verify which merges a hash of name/value pairs into the response's headers hash if the prerequisites cannot be satisfied. [Sam Stephenson] - ex. verify :only => :speak, :method => :post, - :render => { :status => 405, :text => "Must be post" }, + ex. verify :only => :speak, :method => :post, + :render => { :status => 405, :text => "Must be post" }, :add_headers => { "Allow" => "POST" } * Added ActionController.filter_parameter_logging that makes it easy to remove passwords, credit card numbers, and other sensitive information from being logged when a request is handled #1897 [jeremye@bsa.ca.gov] @@ -2221,7 +2249,7 @@ superclass' view_paths. [Rick Olson] <% content_tag :div, :class => "strong" %> Hello world! <% end %> - + Will output:
Hello world!
@@ -2274,7 +2302,7 @@ superclass' view_paths. [Rick Olson] Gives: - + Which is needed for dealing with the IE6 DOM when it's not yet fully loaded. * Fixed that rescue template path shouldn't be hardcoded, then it's easier to hook in your own #6295 [Mike Naberezny] @@ -2329,9 +2357,9 @@ superclass' view_paths. [Rick Olson] * Added proper getters and setters for content type and charset [David Heinemeier Hansson]. Example of what we used to do: response.headers["Content-Type"] = "application/atom+xml; charset=utf-8" - + ...now: - + response.content_type = Mime::ATOM response.charset = "utf-8" @@ -2366,7 +2394,7 @@ superclass' view_paths. [Rick Olson] * Fixed JavaScriptHelper#link_to_function and JavaScriptHelper#button_to_function to have the script argument be optional [David Heinemeier Hansson]. So what used to require a nil, like this: link_to("Hider", nil, :class => "hider_link") { |p| p[:something].hide } - + ...can be written like this: link_to("Hider", :class => "hider_link") { |p| p[:something].hide } @@ -2380,7 +2408,7 @@ superclass' view_paths. [Rick Olson] * Fixed that AssetTagHelper#image_tag and others using compute_public_path should not modify the incoming source argument (closes #5102) [eule@space.ch] -* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] +* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] * Fixed FormOptionsHelper#select to respect :selected value #5813 @@ -2546,7 +2574,7 @@ superclass' view_paths. [Rick Olson] class WeblogController < ActionController::Base def index @posts = Post.find :all - + respond_to do |format| format.html format.xml { render :xml => @posts.to_xml } @@ -2554,26 +2582,26 @@ superclass' view_paths. [Rick Olson] end end end - + # returns HTML when requested by a browser, since the browser # has the HTML mimetype at the top of its priority list Accept: text/html - GET /weblog - - # returns the XML + GET /weblog + + # returns the XML Accept: application/xml - GET /weblog + GET /weblog - # returns the HTML + # returns the HTML Accept: application/xml GET /weblog.html # returns the XML Accept: text/html GET /weblog.xml - + All this relies on the fact that you have a route that includes .:format. - + * Expanded :method option in FormTagHelper#form_tag, FormHelper#form_for, PrototypeHelper#remote_form_for, PrototypeHelper#remote_form_tag, and PrototypeHelper#link_to_remote to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [David Heinemeier Hansson] * Added :method option to UrlHelper#link_to, which allows for using other verbs than GET for the link. This replaces the :post option, which is now deprecated. Example: link_to "Destroy", person_url(:id => person), :method => :delete [David Heinemeier Hansson] @@ -2595,7 +2623,7 @@ superclass' view_paths. [Rick Olson] * Use #flush between switching from #write to #syswrite. Closes #4907. [Blair Zajac ] * Allow error_messages_for to report errors for multiple objects, as well as support for customizing the name of the object in the error summary header. Closes #4186. [andrew@redlinesoftware.com, Marcel Molina Jr.] - + error_messages_for :account, :user, :subscription, :object_name => :account * Fix assert_redirected_to tests according to real-world usage. Also, don't fail if you add an extra :controller option: [Rick Olson] @@ -2617,8 +2645,8 @@ superclass' view_paths. [Rick Olson] * Modify routing so that you can say :require => { :method => :post } for a route, and the route will never be selected unless the request method is POST. Only works for route recognition, not for route generation. [Jamis Buck] * Added :add_headers option to verify which merges a hash of name/value pairs into the response's headers hash if the prerequisites cannot be satisfied. [Sam Stephenson] - ex. verify :only => :speak, :method => :post, - :render => { :status => 405, :text => "Must be post" }, + ex. verify :only => :speak, :method => :post, + :render => { :status => 405, :text => "Must be post" }, :add_headers => { "Allow" => "POST" } @@ -2683,7 +2711,7 @@ superclass' view_paths. [Rick Olson] * Added automated timestamping to AssetTagHelper methods for stylesheets, javascripts, and images when Action Controller is run under Rails [David Heinemeier Hansson]. Example: image_tag("rails.png") # => 'Rails' - + ...to avoid frequent stats (not a problem for most people), you can set RAILS_ASSET_ID in the ENV to avoid stats: ENV["RAILS_ASSET_ID"] = "2345" @@ -2703,9 +2731,9 @@ superclass' view_paths. [Rick Olson] * Change #form_for and #fields_for so that the second argument is not required [Dave Thomas] <% form_for :post, @post, :url => { :action => 'create' } do |f| -%> - + becomes... - + <% form_for :post, :url => { :action => 'create' } do |f| -%> * Update to script.aculo.us 1.6 [Thomas Fuchs] @@ -2723,11 +2751,11 @@ superclass' view_paths. [Rick Olson] * Added nicer message for assert_redirected_to (closes #4294) [court3nay] assert_redirected_to :action => 'other_host', :only_path => false - + when it was expecting... - + redirected_to :action => 'other_host', :only_path => true, :host => 'other.test.host' - + gives the error message... response is not a redirection to all of the options supplied (redirection is <{:only_path=>false, :host=>"other.test.host", :action=>"other_host"}>), difference: <{:only_path=>"true", :host=>"other.test.host"}> @@ -2774,11 +2802,11 @@ superclass' view_paths. [Rick Olson] * CHANGED DEFAULT: The default content type for .rxml is now application/xml instead of type/xml, see http://www.xml.com/pub/a/2004/07/21/dive.html for reason [David Heinemeier Hansson] * Added option to render action/template/file of a specific extension (and here by template type). This means you can have multiple templates with the same name but a different extension [David Heinemeier Hansson]. Example: - + class WeblogController < ActionController::Base def index @posts = Post.find :all - + respond_to do |type| type.html # using defaults, which will render weblog/index.rhtml type.xml { render :action => "index.rxml" } @@ -2792,7 +2820,7 @@ superclass' view_paths. [Rick Olson] class WeblogController < ActionController::Base def create @post = Post.create(params[:post]) - + respond_to do |type| type.js { render } # renders create.rjs type.html { redirect_to :action => "index" } @@ -2818,16 +2846,16 @@ superclass' view_paths. [Rick Olson] * Added plugin support for parameter parsers, which allows for better support for REST web services. By default, posts submitted with the application/xml content type is handled by creating a XmlSimple hash with the same name as the root element of the submitted xml. More handlers can easily be registered like this: # Assign a new param parser to a new content type - ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| - node = REXML::Document.new(post) + ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| + node = REXML::Document.new(post) { node.root.name => node.root } end # Assign the default XmlSimple to a new content type ActionController::Base.param_parsers['application/backpack+xml'] = :xml_simple - + Default YAML web services were retired, ActionController::Base.param_parsers carries an example which shows how to get this functionality back. As part of this new plugin support, request.[formatted_post?, xml_post?, yaml_post? and post_format] were all deprecated in favor of request.content_type [Tobias Lütke] - + * Fixed Effect.Appear in effects.js to work with floats in Safari #3524, #3813, #3044 [Thomas Fuchs] * Fixed that default image extension was not appended when using a full URL with AssetTagHelper#image_tag #4032, #3728 [rubyonrails@beautifulpixel.com] @@ -2865,7 +2893,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car page['blank_slate'] # => $('blank_slate'); page['blank_slate'].show # => $('blank_slate').show(); page['blank_slate'].show('first').up # => $('blank_slate').show('first').up(); - + page.select('p') # => $$('p'); page.select('p.welcome b').first # => $$('p.welcome b').first(); page.select('p.welcome b').first.hide # => $$('p.welcome b').first().hide(); @@ -3003,7 +3031,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Add session ID to default logging, but remove the verbose description of every step [David Heinemeier Hansson] * Add the following RJS methods: [Sam Stephenson] - + * alert - Displays an alert() dialog * redirect_to - Changes window.location.href to simulate a browser redirect * call - Calls a JavaScript function @@ -3085,13 +3113,13 @@ Default YAML web services were retired, ActionController::Base.param_parsers car page.visual_effect :highlight, 'list' page.hide 'status-indicator', 'cancel-link' end - + generates the following JavaScript: - + new Insertion.Bottom("list", "
  • Last item
  • "); new Effect.Highlight("list"); ["status-indicator", "cancel-link"].each(Element.hide); - + * Refactored JavaScriptHelper into PrototypeHelper and ScriptaculousHelper [Sam Stephenson] * Update to latest script.aculo.us version (as of [3031]) @@ -3114,12 +3142,12 @@ Default YAML web services were retired, ActionController::Base.param_parsers car <% form_for :person, person, :url => { :action => "update" } do |person_form| %> First name: <%= person_form.text_field :first_name %> Last name : <%= person_form.text_field :last_name %> - + <% fields_for :permission => person.permission do |permission_fields| %> Admin? : <%= permission_fields.check_box :admin %> <% end %> <% end %> - + * options_for_select allows any objects which respond_to? :first and :last rather than restricting to Array and Range. #2824 [Jacob Robbins , Jeremy Kemper] * The auto_link text helper accepts an optional block to format the link text for each url and email address. Example: auto_link(post.body) { |text| truncate(text, 10) } [Jeremy Kemper] @@ -3150,11 +3178,11 @@ Default YAML web services were retired, ActionController::Base.param_parsers car class ApplicationController < ActionController::Base before_filter :authenticate end - + class WeblogController < ApplicationController # will run the :authenticate filter end - + class SignupController < ActionController::Base # will not run the :authenticate filter skip_before_filter :authenticate @@ -3300,7 +3328,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Added easy assignment of fragment cache store through use of symbols for included stores (old way still works too) Before: - ActionController::Base.fragment_cache_store = + ActionController::Base.fragment_cache_store = ActionController::Base::Caching::Fragments::FileStore.new("/path/to/cache/directory") After: @@ -3463,7 +3491,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Added incremental and local autocompleting and loads of documentation to controls.js [Ivan Krstic] * Extended the auto_complete_field helper to accept tokens option * Changed object extension mechanism to favor Object.extend to make script.aculo.us easily adaptable to support 3rd party libs like IE7.js [David Zülke] - + * Fixed that named routes didn't use the default values for action and possible other parameters #1534 [Nicholas Seckar] * Fixed JavascriptHelper#visual_effect to use camelize such that :blind_up will work #1639 [pelletierm@eastmedia.net] @@ -3519,13 +3547,13 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Added support for graceful error handling of Ajax calls #1217 [Jamis Buck/Thomas Fuchs]. Example: link_to_remote( - "test", - :url => { :action => "faulty" }, + "test", + :url => { :action => "faulty" }, :update => { :success => "good", :failure => "bad" }, 403 => "alert('Forbidden- got ya!')", - 404 => "alert('Nothing there...?')", + 404 => "alert('Nothing there...?')", :failure => "alert('Unkown error ' + request.status)") - + * Attempt to explicitly flush the output at the end of CgiProcess#out * Fixed assert_redirected_to to handle absolute controller paths properly #1472 [Rick Olson/Nicholas Seckar] @@ -3536,7 +3564,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Fixed prototype to consider all fields it doesn't know as text (such as Safari's search) just like the browser in its serialization #1497 [Sean Treadway] -* Improved performance of Routes generation by a factor of 5 #1434 [Nicholas Seckar] +* Improved performance of Routes generation by a factor of 5 #1434 [Nicholas Seckar] * Added named routes (NEEDS BETTER DESCRIPTION) #1434 [Nicholas Seckar] @@ -3567,8 +3595,8 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Correct distance_of_time_in_words for integer arguments and make the second arg optional, treating the first arg as a duration in seconds. #1458 [madrobby ] -* Fixed query parser to deal gracefully with equal signs inside keys and values #1345 [gorou]. - Example: /?sig=abcdef=:foobar=&x=y will pass now. +* Fixed query parser to deal gracefully with equal signs inside keys and values #1345 [gorou]. + Example: /?sig=abcdef=:foobar=&x=y will pass now. * Added Cuba to country list #1351 [todd] @@ -3588,7 +3616,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Ensure that helpers are only available to the controllers where they are defined and their subclasses. #1394 [kdole@tamu.edu] -* render("foo/bar") works with a layout again +* render("foo/bar") works with a layout again * Fixed double-singularization on scaffolded pagination call (Address would be turned into Addres) #1216, #1404 [nilsga] @@ -3636,7 +3664,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car | render_text "hello world!" | render :text => "hello world!" | | render_partial_collection "person", @people, nil, :a => 1 | render :partial => "person", :collection => @people, | | | :locals => { :a => 1 } | - +---------------------------------------------------------------+-------------------------------------------------------+ + +---------------------------------------------------------------+-------------------------------------------------------+ * Deprecated redirect_to_path and redirect_to_url in favor of letting redirect_to do the right thing when passed either a path or url. @@ -3664,7 +3692,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car Content-Type: application/xml HelloWorld - + ...is the same as: Content-Type: application/x-yaml @@ -3673,11 +3701,11 @@ Default YAML web services were retired, ActionController::Base.param_parsers car content: HelloWorld ...is the same as: - + item[content]=HelloWorld - + Which in the end turns into { "item" => { "content" => "HelloWorld" } }. This makes it a lot easier to publish REST web services on top of your regular actions (as they won't care). - + Example Curl call: curl -H 'Content-Type: application/xml' -d 'KillMeMore' http://www.example.com/service @@ -3721,11 +3749,11 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Removed dumping of template assigns on the rescue page as it would very easily include a ton of data making page loads take seconds (and the information was rarely helpful) #1222 * Added BenchmarkHelper that can measure the execution time of a block in a template and reports the result to the log. Example: - + <% benchmark "Notes section" do %> <%= expensive_notes_operation %> <% end %> - + Will add something like "Notes section (0.345234)" to the log. * Added ActionController::Caching::Sweeper as an improved an easier to use sweeper. The new sweepers work on a single-step approach instead of two-steps like the old ones. Before @@ -3733,7 +3761,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car def after_save(record) @list = record.is_a?(List) ? record : record.list end - + def filter(controller) controller.expire_page(:controller => "lists", :action => %w( show public feed ), :id => @list.id) controller.expire_action(:controller => "lists", :action => "all") @@ -3750,7 +3778,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car end The new sweepers can also observe on the actions themselves by implementing methods according to (before|after)_$controller_$action. Example of a callback that'll be called after PagesController#update_title has been performed: - + def after_pages_update_title expire_fragment(%r{pages/#{controller.assigns["page"].id}/.*}) end @@ -3789,16 +3817,16 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Added a wide range of new Javascript effects: * Effect.Puff zooms the element out and makes it smoothly transparent at the same time, giving a "puff" illusion #996 [thomas@fesch.at] - After the animation is completed, the display property will be set to none. + After the animation is completed, the display property will be set to none. This effect will work on relative and absolute positioned elements. - + * Effect.Appear as the opposite of Effect.Fade #990 [thomas@fesch.at] You should return elements with style="display:none;" or a like class for this to work best and have no chance of flicker. - + * Effect.Squish for scaling down an element and making it disappear at the end #972 [thomas@fesch.at] - + * Effect.Scale for smoothly scaling images or text up and down #972 [thomas@fesch.at] - + * Effect.Fade which smoothly turns opacity from 100 to 0 and then hides the element #960 [thomas@fesch.at] * Added Request#xml_http_request? (and an alias xhr?) to that'll return true when the request came from one of the Javascript helper methods (Ajax). This can be used to give one behavior for modern browsers supporting Ajax, another to old browsers #1127 [Sam Stephenson] @@ -3806,11 +3834,11 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Changed render_partial to take local assigns as the second parameter instead of an explicit object and then the assigns. So the API changes from: <%= render_partial "account", person, "rules" => regulations.rules %> - + ...to: - + <%= render_partial "account", :account => person, :rules => regulations.rules %> - + The old API will still work, though, and render_partial "account" will still assume :account => @account. * Added support for web servers that use PATH_INFO instead of REQUEST_URI like IIS #1014 [BradG/Nicholas Seckar] @@ -3951,7 +3979,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car flash.now[:message] = 'Save failed, review' render_action 'edit' end - end + end end * Added to_param call for parameters when composing an url using url_for from something else than strings #812 [Sam Stephenson]. Example: @@ -3989,7 +4017,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car A request for /categories/top-level-cat, would give @params[:path_info] with "top-level-cat". A request for /categories/top-level-cat/level-1-cat, would give @params[:path_info] with "top-level-cat/level-1-cat" and so forth. - + The @params[:path_info] return is really an array, but where to_s has been overwritten to do join("/"). * Fixed options_for_select on selected line issue #624 [Florian Weber] @@ -4110,11 +4138,11 @@ Default YAML web services were retired, ActionController::Base.param_parsers car def test_create_post post :create, "post" => { "title" => "Exciting!" } assert_redirected_to :action => "show" - + follow_redirect assert_rendered_file "post/show" end - + Limitation: Only works for redirects to other actions within the same controller. * Fixed double requiring of models with the same name as the controller @@ -4139,9 +4167,9 @@ Default YAML web services were retired, ActionController::Base.param_parsers car <%= text_field "student[]", "last_name" %> <%= text_field "student[]", "grade", :size => "5" %> <% end %> - + ...would produce, for say David Black with id 123 and a grace of C+: - + @@ -4171,7 +4199,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car class WeblogController before_filter { |c| c.send(:redirect_to_url("http://www.farfaraway.com")}) } - + def hello render_text "I will never be called" end @@ -4184,7 +4212,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car redirect_to :action => "elsewhere" render_action "overthere" end - + Only the redirect happens. The rendering call is simply ignored. @@ -4194,12 +4222,12 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Added assert_cookie_equal to assert the contents of a named cookie -* Fixed bug in page caching that prevented it from working at all +* Fixed bug in page caching that prevented it from working at all *1.3.0* (January 17th, 2005) -* Added an extensive caching module that offers three levels of granularity (page, action, fragment) and a variety of stores. +* Added an extensive caching module that offers three levels of granularity (page, action, fragment) and a variety of stores. Read more in ActionController::Caching. * Added the option of passing a block to ActiveRecordHelper#form in order to add more to the auto-generated form #469 [dom@sisna.com] @@ -4238,9 +4266,9 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Fixed three issues with retrying breakpoints #417 [Florian Gross] - 1. Don't screw up pages that use multiple values for the same parameter (?foo=bar&foo=qux was converted to ?foo=barqux) - 2. Don't screw up all forms when you click the "Retry with Breakpoint" link multiple times instead of reloading - (This caused the parameters to be added multiple times for GET forms leading to trouble.) + 1. Don't screw up pages that use multiple values for the same parameter (?foo=bar&foo=qux was converted to ?foo=barqux) + 2. Don't screw up all forms when you click the "Retry with Breakpoint" link multiple times instead of reloading + (This caused the parameters to be added multiple times for GET forms leading to trouble.) 3. Don't add ?BP-RETRY=1 multiple times * Added that all renders and redirects now return false, so they can be used as the last line in before_filters to stop execution. @@ -4252,7 +4280,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car return false end end - + After: def authenticate redirect_to(:controller => "account", :action => "login") unless @session[:authenticated] @@ -4263,7 +4291,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car class JournalController < ActionController::Base # only require authentication if the current action is edit or delete before_filter :authorize, :only_on => [ :edit, :delete ] - + private def authorize # redirect to login unless authenticated @@ -4307,7 +4335,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Added more informative exception when using helper :some_helper and the helper requires another file that fails, you'll get an error message tells you what file actually failed to load, rather than falling back on assuming it was the helper file itself #346 [dblack] -* Added use of *_before_type_cast for all input and text fields. This is helpful for getting "100,000" back on a integer-based +* Added use of *_before_type_cast for all input and text fields. This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100". * Added Request#port_string to get something like ":8080" back on 8080 and "" on 80 (or 443 with https). @@ -4354,15 +4382,15 @@ Default YAML web services were retired, ActionController::Base.param_parsers car scaffold :<%= singular_name %> <% end %> helper :post - + ...produces this on post as singular_name: class SomeController < ApplicationController - + scaffold :post - + helper :post - + ...where as: class SomeController < ApplicationController @@ -4370,18 +4398,18 @@ Default YAML web services were retired, ActionController::Base.param_parsers car scaffold :<%= singular_name %> <% end -%> helper :post - + ...produces: class SomeController < ApplicationController scaffold :post helper :post - + [This undocumented gem for ERb was uncovered by bitsweat] * Fixed CgiRequest so that it'll now accept session options with Symbols as keys (as the documentation points out) [Suggested by Andreas] -* Added that render_partial will always by default include a counter with value 1 unless there is a counter passed in via the +* Added that render_partial will always by default include a counter with value 1 unless there is a counter passed in via the local_assigns hash that overrides it. As a result, render_collection_of_partials can still be written in terms of render_partial and partials that make use of a counter can be called without problems from both render_collection_of_partials as well as render_partial #295 [Marcel Molina Jr.] @@ -4396,12 +4424,12 @@ Default YAML web services were retired, ActionController::Base.param_parsers car link:classes/ActionController/Base.html#M000021. It's also possible to pass a string instead of an options hash to get a link tag that just points without consideration. The html_options works jointly for the image and ahref tag by letting the following special values enter the options on the image and the rest goes to the ahref: - + ::alt: If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension) ::size: Supplied as "XxY", so "30x45" becomes width="30" and height="45" ::align: Sets the alignment, no special features - - The +src+ can be supplied as a... + + The +src+ can be supplied as a... * full path, like "/my_images/image.gif" * file name, like "rss.gif", that gets expanded to "/images/rss.gif" * file name without extension, like "logo", that gets expanded to "/images/logo.png" @@ -4416,10 +4444,10 @@ Default YAML web services were retired, ActionController::Base.param_parsers car # Calls Controller#miletone with a GET request process :milestone - + # Calls Controller#miletone with a POST request that has parameters post :milestone, { "name" => "David" } - + # Calls Controller#milestone with a HEAD request that has both parameters and session data head :milestone, { "id" => 1 }, { "user_id" => 23 } @@ -4429,7 +4457,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Added indifference to whether @headers["Content-Type"], @headers["Content-type"], or @headers["content-type"] is used. -* Added TestSession#session_id that returns an empty string to make it easier to functional test applications that doesn't use +* Added TestSession#session_id that returns an empty string to make it easier to functional test applications that doesn't use cookie-based sessions #275 [jcf] * Fixed that cached template loading would still check the file system to see if the file existed #258 [Andreas Schwarz] @@ -4444,9 +4472,9 @@ Default YAML web services were retired, ActionController::Base.param_parsers car cookies["user_name"] = "david" # => Will set a simple session cookie cookies["login"] = { "value" => "XJ-122", "expires" => Time.now + 360} # => Will set a cookie that expires in 1 hour - + Examples for reading: - + cookies["user_name"] # => "david" cookies.size # => 2 @@ -4481,14 +4509,14 @@ Default YAML web services were retired, ActionController::Base.param_parsers car class MsgController < ApplicationController helper :msg end - + ...you can just do: - + class MsgController < ApplicationController end * Added dependencies_on(layer) to query the dependencies of a controller. Examples: - + MsgController.dependencies_on(:model) # => [ :post, :comment, :attachment ] MsgController.dependencies_on(:service) # => [ :notification_service ] MsgController.dependencies_on(:observer) # => [ :comment_observer ] @@ -4543,7 +4571,7 @@ Default YAML web services were retired, ActionController::Base.param_parsers car class WeblogController < ActionController::Base include WeblogHelper end - + After: module WeblogHelper @@ -4579,10 +4607,10 @@ Default YAML web services were retired, ActionController::Base.param_parsers car * Changed scaffolding of forms to use