Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Last active August 29, 2015 14:18
Show Gist options
  • Save pier-oliviert/96d1b968cbdbb22f1e50 to your computer and use it in GitHub Desktop.
Save pier-oliviert/96d1b968cbdbb22f1e50 to your computer and use it in GitHub Desktop.
class Post
def year
self.published_at.month
end
def month
self.published_at.month
end
def to_params
self.slug
end
end
Application.routes.draw do
get '/:year/:month/:id', controller: :posts, action: :show, constraints: { year: /\d+/, month: /\d+/ }, as: "post"
end
post_path(post)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment