Skip to content

Instantly share code, notes, and snippets.

@rn0
Forked from robertsosinski/application.rb
Created June 19, 2011 18:51
Show Gist options
  • Save rn0/1034594 to your computer and use it in GitHub Desktop.
Save rn0/1034594 to your computer and use it in GitHub Desktop.
A simple way to manage multiple parameters in Rails routing
before_filter :hash_options
def hash_options
params[:options] = Hash[*((params[:options].size % 2) == 0) ? params[:options] : (params[:options] + [nil])] if params[:options]
end
map.connect ':controller/:action/*options'
<a href="/pages/show/<%= "user_name/#{@user_name}/date/#{@date}" %>">Link</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment