Skip to content

Instantly share code, notes, and snippets.

@chrisconley
Created December 15, 2009 16:17
Show Gist options
  • Select an option

  • Save chrisconley/257049 to your computer and use it in GitHub Desktop.

Select an option

Save chrisconley/257049 to your computer and use it in GitHub Desktop.
map.connect 'questions/:id/:tags/:question',
:controller => 'questions',
:action => 'show',
:tags => 'question',
:question => nil
module ApplicationHelper
def question_path(question, extra_params=true)
options = {}
if extra_params
options[:tags] = question.keyword_list.join('-').downcase.gsub(/\s+/, '-') unless question.keyword_list.blank?
options[:question] = question.question.split(/\W+/).join('-').downcase unless question.question.blank?
end
options[:only_path] = true
options[:controller] = 'questions'
options[:action] = 'show'
options[:id] = question.id
url_for options
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment