Simple Datamapper plugin for referencing Resources by 'URL slugs'.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.DS_Store
.gitignore
History.txt
LICENSE
Manifest.txt
README.markdown
README.txt
Rakefile
TODO
dm-is-sluggable.gemspec

README.markdown

dm-is-sluggble

DataMapper plugin that allows records to be found as a slug, mostly used in pretty urls.

Example DataMapper resource (i.e. model)

# /app/models/post.rb
class Post
  include DataMapper::Resource

  property :id, Serial
  property :slug, String
  
  is :sluggable
  
end

@post = Post.create
@post.slug # => "@1"
Post.by_slug # => @post

@post.update_attributes(:slug => 'some-slug-here')
@post.slug # => "some-slug-here"
Post.by_slug # => @post

Example Merb route

# /config/routes.rb
identify(Post => :slug) do
  resources :posts
end

# url(:post, 1) => /posts/some-slug-here