KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-21 17:43 UTC
Does anyone know how to write an additional attribute to the TAGS table?
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld
2007-Jul-22 07:57 UTC
Re: Does anyone know how to write an additional attribute to
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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 .. ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-22 12:58 UTC
Re: Does anyone know how to write an additional attribute to
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 Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> KathysK...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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 .. > > ? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld
2007-Jul-22 13:12 UTC
Re: Does anyone know how to write an additional attribute to
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 > endyou''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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Obie Fernandez
2007-Jul-22 14:11 UTC
Re: Does anyone know how to write an additional attribute to
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, KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > KathysK...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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 .. > > > > ? > > > > -- > > Posted viahttp://www.ruby-forum.com/. > > > > >-- Obie Fernandez http://jroller.com/obie/ Pre-order my book The Rails Way today! http://www.amazon.com/dp/0321445619 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---