mbleigh/acts-as-taggable-on — Issue #199: Accessing .tags before save breaks expected behavior
Author: zorn
Created: 2011-10-26 18:56:58+00:00
State: open

Just getting started with using acts-as-taggable-on. Looks great but ran into a bug. In my Rails 3.0.9 app I did the standard setup and added "acts_as_taggable" to my SessionDescription model and fired up ERB. The bug: If I access the tags collection before I set the tag_list attribute and save I doesn't seems to work right. See my sample usage below.

BROKEN:

irb(main)> food = SessionDescription.new
=> #
irb(main)> food.name = "Food"
=> "Food"
irb(main)> food.tags
=> []
irb(main)> food.tag_list = "apple, pear"
=> "apple, pear"
irb(main)> food.tags
=> []
irb(main)> food.save
=> true
irb(main)> food.tags
=> []

WORK AROUND (save before accessing .tags):

irb(main)> soda = SessionDescription.new
=> #
irb(main)> soda.name = "Soda"
=> "Soda"
irb(main)> soda.tag_list = "pepsi, coke"
=> "pepsi, coke"
irb(main)> soda.save
=> true
irb(main)> soda.tags
=> [#, #]