Created
November 19, 2012 13:58
-
-
Save huobazi/4110779 to your computer and use it in GitHub Desktop.
提取URL参数
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
# in routes.rb | |
match 'items/*query' => 'items#index' | |
if params[:query] | |
hash = Hash.new | |
query = params[:query].split('/') | |
index = 0 | |
while index < query.length && query[index +1] | |
hash[query[index]] = query[index + 1] | |
index = index + 2 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment