Acts_as_taggable and new taggable items

I just brought acts_as_taggable into an app and I have one question.
Is the following the best way to tag a brand new taggable item? (Note:
I’m grabbing the data from a form - I cut the code down to its basics
for the post.)

def save_story
story =[:story])

Near as I can tell, it’s not possible to successfully tag a taggable
item until the item has an id. Saving the item once before tagging
will generate that id for me, allowing me to save the item a second
time, which registers the tagging information.

Thought I’d ping the group. Anyone with solid acts_as_taggable
experience who can tell me a better way to do the above?

I do not believe there is a better way to do this. The id must be
first to be stored in the taggable join table.

On 1/12/07, bjhess [email protected] wrote:

Try keeping your controller skinny by adding accessors and callbacks
to your model.

class Story < ActiveRecord::Base
after_save :tagify
attr_accessor :tag_list

def tagify
self.tag_list = tag_list.split(‘,’) if tag_list.is_a? String #
comma, or whatever
tag_list.each { |tag| tag_with(tag) }

Now, in your controller:

def save_story

Chris W.

Ask and you shall receive - check this out: