Sha256: c367bac6919e7e24dc3ea634ea8c2f3081707227622ec57e153eb62448962ab4
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
= SlugEngine SlugEngine provides an easy, reusable method of adding permalinks to your content. == Getting Started First, add `gem 'slug_engine'` to your `Gemfile` and run `bundle install`. Second, mount the `SlugEngine` in `config/routes.rb` at the appropriate location. My::Application.routes.draw do # some REST-ful routes resources :posts # the SlugEngine mount Slug::Engine => "/" end It's best if you place the `SlugEngine` after your other routes, but this is not required. If the `SlugEngine` cannot find a matching slug, it will abstain from handling the request, allowing lower priority routes or other engines to take a stab at the request. If no further routes match, the normal 404 page will be returned. You can use a prefix with your slugs if you like: My::Application.routes.draw do # some REST-ful routes resources :posts # the SlugEngine mount Slug::Engine => "/p" end This will match requests like `"http://www.example.com/p/my-slug"` where `'my-slug'` is the matched slug. When authoring your content, `'/p'` will not be considered part of the slug, e.g., `p = Post.create :title => 'My Post', :slug => 'my-slug'` would still resolve when accessed at `"http://www.example.com/p/my-slug"` if the engine was prefixed.
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
slug-engine-0.0.3 | README.rdoc |
slug-engine-0.0.2 | README.rdoc |
slug-engine-0.0.1 | README.rdoc |