Michael Peralta
Michael Peralta

Reputation: 293

Acts_as_taggable_on implementation tutorial

I've been trying to allow for tags to be placed on posts so that I could partition them into different sections of my app. I've looked through various gems and have found that acts_as_taggable_on seems to be the most popular one. After various attempts of implementation from the examples in the github of the gem I have not been able to successfully use it. I've searched extensively for a tutorial on implementation but have found none and was hoping someone would have one for such a thing. I'm sorry for the simple question as I am still relatively new to programming.

Upvotes: 1

Views: 3357

Answers (2)

jfdimark
jfdimark

Reputation: 2369

Railscasts now has an excellent tutorial on acts_as_taggable. This is also a nice and simple text intro on how to get it working.

Upvotes: 2

Matthew Doering
Matthew Doering

Reputation: 321

There are a number of tutorials that are just fine. The one mentioned in the previous answer is a good one.

One point that is not obvious to someone new to the RoR world is that there is no actual column in the database for the tags on the target table. I have seen many folks add a "tags" column to their database. No need for that at all and it just confuses things.

When you add the "acts_as_taggable_on :tags" to the model it becomes a virtual column (I know its not a RoR way to express this but if you have a database background its easier to think this way).

If you are going to require that tags have owners follow the example on how to get an objects tags carefully. You can only get that objects tags via "tags_from". You will get a null if you try a simple tags_list.

Hope this helps

Upvotes: 0

Related Questions