-
Notifications
You must be signed in to change notification settings - Fork 4
Home
ratbeard edited this page Sep 13, 2010
·
13 revisions
It’s providing tagging support to DataMapper resources.
- install ‘dm-is-remixable’, if you do not have it
- git clone git://github.com/maxime/dm-is-taggable.git
- cd dm-is-taggable
- sudo rake install
- dependency ‘dm-is-taggable’ in your init.rb
- In your model:
class Post
include DataMapper::Resource
property :id, Serial
property :name, String
property :description, Text
is :taggable
end
post = Post.create(:name => "My First Post")
tasty = Tag.build('tasty')
original = Tag.build('original')
post.tag(tasty)
post.tag(original)
post.tags #=> [tasty, original]
tasty.posts #=> [post]
original.posts #=> [post]
post.untag(tasty)
post.tags.reload
post.tags #=> [original]
class User
include DataMapper::Resource
property :id, Serial
property :login, String
end
class Post
include DataMapper::Resource
property :id, Serial
property :name, String
property :description, Text
is :taggable, :by => [User]
end
bob = User.create(:login => 'bob')
book = Book.create(:title => "Wonderful world", :isbn => "1234567890123", :author => "Awesome author")
fiction = Tag.build('fiction')
english = Tag.build('english')
bob.tag(book, :with => scifi)
bob.books #=> book
book.tags #=> scifi
- More Specs / Testing
- Publish on Rubyforge
- A form helper