Does anyone know how to write an additional attribute to the

I’m enjoying using acts_as_taggable and am trying many ways to write
an addtional integer key field to the tag.rb so it can in turn
belong_to a parent table.
I’ve tried opening up the acts_as_taggable.rb trying to find a way to
add another attribute but it’s so WEIRD??
Then, I thought I would simply use a before_create callback on the
tag.rb model. Inside the controller.action that calls this method
there are some instance variables available. However, when I reference
this instance variable while taking a slight detour into the tag.rb
code it becomes unavailable?
In the controller.create I call this code:
@rateme = @slicehit.ratemes.new(params[:rateme])
@rateme.user = current_user
@rateme.tag_with params[:tags] if params[:tags]
respond_to do |format|
if @rateme.save

However in the before_create code in the TAG model I use this;
def after_create
self.portal_id = @slicehit.portal_id
end
I always get the “nil.portal_id error”, although you can see the
@slicehit is healthy in the calling code?
Has anyone out there ever modified this part of acts_as_taggable?
Thank you,
Kathy

[email protected] wrote:

I’m enjoying using acts_as_taggable and am trying many ways to write
an addtional integer key field to the tag.rb so it can in turn
belong_to a parent table.

why would you want to do this? what use do u need for a belongs_to for
tags?
the whole idea of tags is that it belongs_to

belongs_to :taggable, :polymorphic => true

anything you want. you don’t need to add a belong_to statement; it is
true for each ‘taggable’ you define. ( you turn a model into a
‘taggable’ object by adding the acts_as_taggable statement to the model.
)

i may be missing something, though …

?

Shai,
Good question. I am writing on application that will serve MANY
distinct domains by scoping the request.host. Many of these are
entirely unrelated and thus my need to add a key integer field to the
tag.rb.
Somehow by putting the acts_as_? behavior on top of this object makes
it act extraordinary and I can’t accomplish adding a row.column value
to the record. This is a fundamental need and I can’t make headway. I
am using the before_create callback and it just passes through without
ever appearing to fire. Here’s the code on callback:
def after_create
self.portal = @portal.id
end
Do you know anyone I could hire to make this happen?
Thank you,
Kathleen

On Jul 22, 2:57 am, Shai R. [email protected]

ok, so not that i have any real idea what EXACTLY you want to do, but
just reading through what you’ve wrote:

am using the before_create callback and it just passes through without
ever appearing to fire. Here’s the code on callback:
def after_create
self.portal = @portal.id
end

you’re using ** after_create ** rather than ** before_create ** and that
in itself should be a good enough reason you aren’t saving anything -
you are assigning
“self.portal” after the record is saved.

this looks like a stupid solution to a bigger problem you’re having, but
if this IS the prob, … there you go.

hth

I saw your original message and would like to help, but I don’t think
it contained enough of your code to diagnose the problem. At least
post the models…

Obie

On 7/22/07, [email protected] [email protected] wrote:

ever appearing to fire. Here’s the code on callback:

I’m enjoying using acts_as_taggable and am trying many ways to write
true for each ‘taggable’ you define. ( you turn a model into a


Obie F.

Pre-order my book The Rails Way today!
http://www.amazon.com/dp/0321445619