Showing posts with label rubyonrails. Show all posts
Showing posts with label rubyonrails. Show all posts

Nov 25, 2006

rails code dissection


The first article on The Rails Way reviews the code of Tracks, a Rails site based on GTD.
I took note of the site when I saw it was co-run by Capistrano creator and Rails core team member Jamis Buck.

I really like the formatting and display of the code samples and the layout in general looks nice enough that I'm keen to try out Mephisto. Hopefully the layout sugar comes free with it.

The actual discussion of the code is great. I'm looking forward to future posts!

Nov 8, 2006

RubyOnRails pagination fix

update: Rails Pagination is ugly and will be deprecated.

Here's a fix I made to get around a problem in Rails Pagination.


# pagination links do not support all form objects properly
# a hash with values such as date[year], date[month] and date[day]
# will be included in the pagination link as date=month11day9year2006
#
# putting this function in application_helper.rb and calling it from your
# view will properly construct the pagination links to include your form
# input
#
# <%= pagination_links(@cdr_pages, :params => marshall_objects(params)) %>
#
def marshall_objects(params)
params.each do |key, val|
if val.class == HashWithIndifferentAccess
params[key] = nil
val.each {|sub_key, sub_val| params[key + '[' + sub_key + ']'] = sub_val}
end
end
params
end