routes - Drupal-like routing system in Rails -
i trying find best-practice allow users define route pages in rails, writing them in text field when submitting posts, path module in drupal (yes, porting drupal site rails)
so, need to
- define new, named route on article submission (eg http://www.domain.com/a-day-in-annas-life)
- change existing route on article edit, if define new one, doing 301 redirect old route new 1
how can best achieve this?
okay, found way, if it's best practice or not, cant say.
i using custom restrictor's this:
class charitiesrestrictor def self.matches?(request) slug = request.path_parameters[:path] !charity.find_by_name(slug).nil? end end constraints charitiesrestrictor match '*path' => 'charities#show_by_slug', :constraints => charitiesrestrictor.new end
when create block each of model/controller pairs should able respond permalinks, can have them have chance act on permalink. however, means called in series, not ideal.
Comments
Post a Comment