0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Super lightweight alternative to all the other tagging gems out there.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0
 Project Readme

TaggingAlong

Super lightweight alternative to all the other tagging gems out there.

Installation

Add this line to your application's Gemfile:

gem 'tagging_along'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tagging_along

Usage

Include the gem in the model you want to use it with:

class User
  include TaggingAlong
end

and define the attributes that are taggable inside the class:

class User
  include TaggingAlong
  attr_accessor :cars

  is_taggable_on :cars
end

Instances of your class will now have taggable attributes. For example:

user = User.new
user.cars = 'Audi,BMW'

user.cars_tags
# => ['Audi', 'BMW']

user.cars_list
# => 'Audi, BMW'

You can also specify a custom separator:

class User
  include TaggingAlong
  attr_accessor :cars

  is_taggable_on :cars, separator: ':'
end

which will play out like this:

user = User.new
user.cars = 'Audi:BMW'

user.cars_tags
# => ['Audi', 'BMW']

user.cars_list
# => 'Audi: BMW'

You can define multiple taggable attributes in one go:

class User
  include TaggingAlong
  attr_accessor :cars, :qualifications

  is_taggable_on :cars, :qualifications
end

That's it!

Testing

If you use RSpec, you can check if your model is taggable like this:

User.should be_taggable_on :cars

Contributing

  1. Fork it ( https://github.com/CrowdCurity/tagging_along/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request