Friday, 5 October 2007

Rails 1.2.4 changelogs

The latest - and last - release in the Rails 1.2.x familly.

Rails 1.2.4 changelogs

http://dev.rubyonrails.org/changeset/7741

Indivitual changelogs : actionpack, activerecord, activesupport, railsties

root/tags/rel_1-2-4/railties/CHANGELOG 1.2.4 (October 4th, 2007)

  • Add a new rake task to aid debugging of named routes. rake routes
  • use Gem.find_name instead of search when freezing gems. Prevent false positives for other gems with rails in the name. Closes #8729 [wselman]
  • Fix syntax error in dispatcher than wrecked failsafe responses. #8625 [mtitorenko]
  • Add Active Resource to rails:freeze:edge and drop Action Web Service. #8205 [underbluewaters, Jeremy Kemper]
  • Give generate scaffold a more descriptive database message. Closes #7316 [jeremymcanally]
  • Canonicalize RAILS_ROOT by using File.expand_path on Windows, which doesn’t have to worry about symlinks, and Pathname#realpath elsewhere, which respects symlinks in relative paths but is incompatible with Windows. #6755 [Jeremy Kemper, trevor]

root/tags/rel_1-2-4/activesupport/CHANGELOG 1.4.3 (October 4th, 2007)

  • Demote Hash#to_xml to use XmlSimple#xml_in_string so it can’t read files or stdin. #8453 [candlerb, Jeremy Kemper]
  • Document Object#blank?. #6491 [Chris Mear]
  • Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar]
  • Improved multibyte performance by relying less on exception raising #8159 [Blaine]

root/tags/rel_1-2-4/activerecord/CHANGELOG 1.15.4 (October 4th, 2007)

  • Fix #count on a has_many :through association so that it recognizes the :uniq option. Closes #8801 [lifofifo]
  • Don’t clobber includes passed to has_many.count [danger]
  • Make sure has_many uses :include when counting [danger]
  • Save associated records only if the association is already loaded. #8713 [blaine]
  • Changing the :default Date format doesn’t break date quoting. #6312 [bshand, Elias]
  • Allow nil serialized attributes with a set class constraint. #7293 [sandofsky]
  • belongs_to assignment creates a new proxy rather than modifying its target in-place. #8412 [mmangino@elevatedrails.com]
  • Fix column type detection while loading fixtures. Closes #7987 [roderickvd]
  • Document deep eager includes. #6267 [Josh Susser, Dan Manges]
  • Oracle: extract column length for CHAR also. #7866 [ymendel]
  • Small additions and fixes for ActiveRecord documentation. Closes #7342 [jeremymcanally]
  • SQLite: binary escaping works with $KCODE=’u’. #7862 [tsuka]
  • Improved cloning performance by relying less on exception raising #8159 [Blaine]

root/tags/rel_1-2-4/actionpack/CHANGELOG 1.13.4 (October 4th, 2007)

  • Only accept session ids from cookies, prevents session fixation attacks. [bradediger]
  • Change the resource seperator from ; to /    ## foos/1;edit ==> foos/1/edit
  • change the generated routes to use the new-style named routes. e.g. new_group_user_path(@group) instead of group_new_user_path(@group). [pixeltrix]
  • Integration tests: introduce methods for other HTTP methods. #6353 [caboose]
  • Improve performance of action caching. Closes #8231 [skaes]
  • Fix errors with around_filters which do not yield, restore 1.1 behaviour with after filters. Closes #8891 [skaes] 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, Chris Wanstrath]
  • Deprecate pagination. Install the classic_pagination plugin (svn://errtheblog.com/svn/plugins/classic_pagination) for forward compatibility, or move to the superior will_paginate plugin (svn://errtheblog.com/svn/plugins/will_paginate). #8157 [Mislav Marohnic]
  • Fix filtered parameter logging with nil parameter values. #8422 [choonkeat]
  • Integration tests: alias xhr to xml_http_request and add a request_method argument instead of always using POST. #7124 [Nik Wakelin, Francois Beausoleil, Wizard]
  • Document caches_action. #5419 [Jarkko Laine]
  • observe_form always sends the serialized form. #5271 [manfred, normelton@gmail.com]
  • Update UrlWriter to accept :anchor parameter. Closes #6771. [octopod]
  • Replace the current block/continuation filter chain handling by an implementation based on a simple loop. Closes #8226 [Stefan Kaes]
  • Return the string representation from an Xml Builder when rendering a partial. #5044 [tpope]
  • Cleaned up, corrected, and mildly expanded ActionPack documentation. Closes #7190 [jeremymcanally]
  • Small collection of ActionController documentation cleanups. Closes #7319 [jeremymcanally]
  • Performance: patch cgi/session/pstore to require digest/md5 once rather than per #initialize. #7583 [Stefan Kaes]
  • Deprecation: verification with :redirect_to => :named_route shouldn’t be deprecated. #7525 [Justin French]

Wednesday, 25 July 2007

yield

Wednesday, 16 May 2007

2. It's best to do one thing really, really well. (Rails refactoring with painless AOP)

I like Google philosophy a lot, especially Thing Number 9 :
  • 9. You can be serious without a suit.
, but that's not the subject of this sermon; today I'd like to tell you about Thing Number Two (TNT) :
  • 2. It's best to do one thing really, really well.
- Amen -, and its IT translation : the "Separation Of Concerns". At the humble coder's level, separated concerns make for a more readable code. Counter example:
1
2
3
4
5
6
def fetch_stuff(*args)
  benchmark = Benchmark.measure{
    Stuff.fetch_all
  }
  puts "time spent: #{benchmark} "
end
It's ugly, but it works. It works, but it's ugly: this code does TWO completely unrelated things:
  1. fetch some stuff, and
  2. benchmark an action, any action
We MUST find a way to separate those 2 concerns: The first and main concern is obvious :
1
2
3
def fetch_stuff
  Stuff.fetch_all # <<--- CONCERN 1 
end
The second concern is easy to code
1
2
3
4
5
6
def generic_benchmarking_method
  benchmark = Benchmark.measure
    action_to_measure   # <<--- (concern 1)       
  }
  puts "time spent : #{benchmark}}" # <<--- CONCERN 2
end   
but it's difficult to connect to the first method, because :
  • users of concern 1 should not have to know about concern 2 => they will just call the first method
  • as the benchmarking action is completely independent from the action it measures, this action should be passed as a parameter in some way
The solution: piggy-back the benchmarking method on the fetching method, transparently. Q: how do you piggy back ? A: with Rails' alias_method_chain , and some "convention over configuration magic"** (** hint: it's all in the methods naming) Take a deep breath and watch the mystery unveil :

Before

1
2
3
4
5
6
def fetch_stuff(*args)
  benchmark = Benchmark.measure{
    Stuff.fetch_all
  }
  puts "time spent: #{benchmark} "
end

After

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# concern 1: just do it.
def fetch_stuff
  Stuff.fetch_all
end

# concern 2: just benchmark it.
def fetch_stuff_with_benchmarking(*args)
  benchmark = Benchmark.measure{
  fetch_stuff_without_benchmarking(*args)
  }
  puts "time spent: #{benchmark} "
end

alias_method_chain :fetch_stuff, :benchmarking
That's it : alias_method_chain wrapped benchmarking around fetch_stuff. After line 14 has been parsed, calls to the original fetch_stuff are redirected to fetch_stuff_with_benchmarking, and fetch_stuff_without_benchmarking points to the original fetch_stuff. It's transparent and automatic. All you have to do is respect the naming convention : with and without. That's it. This method was introduced in Rails a year ago to DRY up the internals. There is no reason your code should not benefit shamelessly from it too. Strive for it. You'll thank me later. API : Articles :