Skip to content

Instantly share code, notes, and snippets.

@huobazi
Created November 19, 2012 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huobazi/4110779 to your computer and use it in GitHub Desktop.
Save huobazi/4110779 to your computer and use it in GitHub Desktop.
提取URL参数
# 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