-
-
Save rn0/1034594 to your computer and use it in GitHub Desktop.
A simple way to manage multiple parameters in Rails routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_filter :hash_options | |
def hash_options | |
params[:options] = Hash[*((params[:options].size % 2) == 0) ? params[:options] : (params[:options] + [nil])] if params[:options] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.connect ':controller/:action/*options' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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