As we've worked on this project, as Ruby and Rails newbies, we've come across a number of things that have surprised us.
Rails Magic Request Processing
The redirect code (see C:\ruby\lib\ruby\gems\1.8\gems\actionpack-1.11.2\lib\action_controller\Base.rb under Windows) is a bit bizarre looking, basically doing a case statement on the format/type of the parameters. We got here by noticing that the parameters we receive on a request are not quite the same after doing a redirect. For example, when an HTML Option dropdown generates a parameter, our controller receives it as a String array. After the redirect, however, it's just a string.
This kind of non-linear processing by the Rails magic has lead us, on several occasions, to write controller tests that do not accurately represent the operation of the browser.
<SELECT MULTIPLE>
How do you pass HTML attributes?
In the .rhtml file, we've got
<%=
options = [["All", ""]] + MemberClassesController::all
html_options = { :size => 10, :multiple => true }
select("member_class_id", "", options, html_options)
%>
and this is rendered as
<select id="member_class_id_" name="member_class_id[]"><option value="">All</option> <option value="1">Regular</option> <option value="2">Associate</option> <option value="3">Friend</option></select>
How do we get it to render as
<select id="member_class_id_" name="member_class_id[]" size="10" multiple> ...
name="xyz[]"
Hmmm... Looking at the above HTML, see the name="member_class_id[]"? I bet that's why the post is returning this as an array to controller, e.g., "member_class_id"=>["2"] in the params hash.
Lessons learned by others
Joel On Software warns about some gotchas in his rant.