Hi folks, Thanks to the community feedback on the 1st version, I''ve come up with a much improved version of the acts_as_taggable mixin. There´s some piece of the action here: http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids-with-rails Cheers Dema -- http://dema.ruby.com.br - Rails from a .NET perspective
This looks amazing! Thanks for sharing it. How is the database schema supposed to look for the tags? I assume we have to create the tags DB table and the many-to-many join table, or do you somehow generate them automatically? On 3-Sep-05, at 11:58 AM, Demetrius Nunes wrote:> Hi folks, > > Thanks to the community feedback on the 1st version, I''ve come up > with a much improved version of the acts_as_taggable mixin. > > There´s some piece of the action here: > http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- > with-rails > > Cheers > Dema > -- > http://dema.ruby.com.br - Rails from a .NET perspective > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
David Teare <dteare@...> writes:> > This looks amazing! Thanks for sharing it. > > How is the database schema supposed to look for the tags? I assume > we have to create the tags DB table and the many-to-many join table, > or do you somehow generate them automatically?Yes, I know this lacks some proper documentation and I´ll add to it soon. But answering your question, yes, you have to create the many-to-many join table yourself. If you use a full model for making the join (the :join_class_name option), remember to add an ''id'' primary key to the table, otherwise, don´t use an ''id'' (if you go with the simpler approach). rgds> On 3-Sep-05, at 11:58 AM, Demetrius Nunes wrote: > > > Hi folks, > > > > Thanks to the community feedback on the 1st version, I''ve come up > > with a much improved version of the acts_as_taggable mixin. > > > > There´s some piece of the action here: > > http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- > > with-rails > > > > Cheers > > Dema > > -- > > http://dema.ruby.com.br - Rails from a .NET perspective > > > > _______________________________________________ > > Rails mailing list > > Rails@... > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
How about an example table def? Dema wrote:> David Teare <dteare@...> writes: > > >>This looks amazing! Thanks for sharing it. >> >>How is the database schema supposed to look for the tags? I assume >>we have to create the tags DB table and the many-to-many join table, >>or do you somehow generate them automatically? > > > Yes, I know this lacks some proper documentation and I´ll add to it soon. > > But answering your question, yes, you have to create the many-to-many join > table yourself. > > If you use a full model for making the join (the :join_class_name option), > remember to add an ''id'' primary key to the table, otherwise, don´t use an ''id'' > (if you go with the simpler approach). > > rgds > > > >>On 3-Sep-05, at 11:58 AM, Demetrius Nunes wrote: >> >> >>>Hi folks, >>> >>>Thanks to the community feedback on the 1st version, I''ve come up >>>with a much improved version of the acts_as_taggable mixin. >>> >>>There´s some piece of the action here: >>>http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- >>>with-rails >>> >>>Cheers >>>Dema >>>-- >>>http://dema.ruby.com.br - Rails from a .NET perspective >>> >>>_______________________________________________ >>>Rails mailing list >>>Rails@... >>>http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>
After much trial and error and Dema''s help, I got this working last night. I am in the process of documenting it in my blog - I''ll post here once it''s done. On 4-Sep-05, at 11:53 AM, San wrote:> How about an example table def? > > > Dema wrote: > >> David Teare <dteare@...> writes: >> >>> This looks amazing! Thanks for sharing it. >>> >>> How is the database schema supposed to look for the tags? I >>> assume we have to create the tags DB table and the many-to-many >>> join table, or do you somehow generate them automatically? >>> >> Yes, I know this lacks some proper documentation and I´ll add to >> it soon. >> But answering your question, yes, you have to create the many-to- >> many join table yourself. If you use a full model for making the >> join (the :join_class_name option), remember to add an ''id'' >> primary key to the table, otherwise, don´t use an ''id'' (if you go >> with the simpler approach). >> rgds >> >>> On 3-Sep-05, at 11:58 AM, Demetrius Nunes wrote: >>> >>> >>> >>>> Hi folks, >>>> >>>> Thanks to the community feedback on the 1st version, I''ve come >>>> up with a much improved version of the acts_as_taggable mixin. >>>> >>>> There´s some piece of the action here: >>>> http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- >>>> with-rails >>>> >>>> Cheers >>>> Dema >>>> -- >>>> http://dema.ruby.com.br - Rails from a .NET perspective >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails@... >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>> >>> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
This is my first shot at documenting acts_as_taggable: http:// tearesolutions.com/blog/ Comments welcome - I will happily expand this to include any use cases anyone is interested in. One thing I plan on adding is a "belongs_to :person" relationship to the TagMessage association; we''ll see how that goes. HTH --Dave. On 4-Sep-05, at 11:53 AM, San wrote:> How about an example table def? > > > Dema wrote: > >> David Teare <dteare@...> writes: >> >>> This looks amazing! Thanks for sharing it. >>> >>> How is the database schema supposed to look for the tags? I >>> assume we have to create the tags DB table and the many-to-many >>> join table, or do you somehow generate them automatically? >>> >> Yes, I know this lacks some proper documentation and I´ll add to >> it soon. >> But answering your question, yes, you have to create the many-to- >> many join table yourself. If you use a full model for making the >> join (the :join_class_name option), remember to add an ''id'' >> primary key to the table, otherwise, don´t use an ''id'' (if you go >> with the simpler approach). >> rgds >> >>> On 3-Sep-05, at 11:58 AM, Demetrius Nunes wrote: >>> >>> >>> >>>> Hi folks, >>>> >>>> Thanks to the community feedback on the 1st version, I''ve come >>>> up with a much improved version of the acts_as_taggable mixin. >>>> >>>> There´s some piece of the action here: >>>> http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- >>>> with-rails >>>> >>>> Cheers >>>> Dema >>>> -- >>>> http://dema.ruby.com.br - Rails from a .NET perspective >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails@... >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>> >>> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Great stuff Dave, thanks. BTW, for anyone else that had the url chopped in their newsreader too: http://tearesolutions.com/blog/ David Teare wrote:> This is my first shot at documenting acts_as_taggable: http:// > tearesolutions.com/blog/ > > Comments welcome - I will happily expand this to include any use cases > anyone is interested in. One thing I plan on adding is a "belongs_to > :person" relationship to the TagMessage association; we''ll see how that > goes. > > HTH > --Dave. > > On 4-Sep-05, at 11:53 AM, San wrote: > >> How about an example table def? >> >> >> Dema wrote: >> >>> David Teare <dteare@...> writes: >>> >>>> This looks amazing! Thanks for sharing it. >>>> >>>> How is the database schema supposed to look for the tags? I >>>> assume we have to create the tags DB table and the many-to-many >>>> join table, or do you somehow generate them automatically? >>>> >>> Yes, I know this lacks some proper documentation and I´ll add to it >>> soon. >>> But answering your question, yes, you have to create the many-to- >>> many join table yourself. If you use a full model for making the >>> join (the :join_class_name option), remember to add an ''id'' primary >>> key to the table, otherwise, don´t use an ''id'' (if you go with the >>> simpler approach). >>> rgds >>> >>>> On 3-Sep-05, at 11:58 AM, Demetrius Nunes wrote: >>>> >>>> >>>> >>>>> Hi folks, >>>>> >>>>> Thanks to the community feedback on the 1st version, I''ve come up >>>>> with a much improved version of the acts_as_taggable mixin. >>>>> >>>>> There´s some piece of the action here: >>>>> http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- >>>>> with-rails >>>>> >>>>> Cheers >>>>> Dema >>>>> -- >>>>> http://dema.ruby.com.br - Rails from a .NET perspective >>>>> >>>>> _______________________________________________ >>>>> Rails mailing list >>>>> Rails@... >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>>> >>>> >>>> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >>
David Teare wrote:> This is my first shot at documenting acts_as_taggable: http://tearesolutions.com/blog/ > > Comments welcome - I will happily expand this to include any use cases > anyone is interested in. One thing I plan on adding is a "belongs_to > :person" relationship to the TagMessage association; we''ll see how that > goes.Thanks a bunch Dave. By the way, the bug when tagging unsaved objects has been fixed and I also added some more explanation (inspired by your post) on how to proper set up the mixin to use. Grab the latest version on the same place: http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids-with-rails -- http://dema.ruby.com.br - Rails from a .NET perspective
Demetrius Nunes wrote:> Hi folks, > > Thanks to the community feedback on the 1st version, I''ve come up with a > much improved version of the acts_as_taggable mixin. > > There´s some piece of the action here: > http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids-with-rails > > Cheers > DemaVery nice work, Demetrius! Any chance for a gem version? I think it would boost popularity pretty much :) thanks, Kristof
automat_svet-ZKwmMI9HCDA@public.gmane.org
2005-Sep-05 14:42 UTC
Re: [ANN] acts_as_taggable v2 - Tagging on Steroids
Hi all, I''m trying to setup act_as_taggable and I really need an advice/ example on how to setup the controller for new articles, new articles are saved but tags_articles and tags tables remain untouched... on development.log i can see this: SQL (0.000850) INSERT INTO tags (`name`, `desc`) VALUES('''', NULL) so.. I think I''m making some trivial error but... till now I can''t figure out which.. thanks automat_svet Il giorno 03/set/05, alle ore 17:58, Demetrius Nunes ha scritto:> Hi folks, > > Thanks to the community feedback on the 1st version, I''ve come up > with a much improved version of the acts_as_taggable mixin. > > There´s some piece of the action here: > http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- > with-rails > > Cheers > Dema > -- > http://dema.ruby.com.br - Rails from a .NET perspective > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
You need to list the tags in the form. Easiest way is a text box. show: <b>Tags:</b> <%=h @item.taglist %> edit: <p><label for="article_taglist">Tags (space separated)</label><br/> <%= text_field 'article', 'taglist' %></p> NB: The code above won't work unless you patch the taggable.rb file, as specified here: Insert these two methods on line 207: # Simplifies IO with forms for the tagging. # Good for displaying in a form (in a text box) def taglist tag_names.join(" ") end # Simplifies IO with forms for the tagging # It is used for bulk updates from a form, and expects that the # full spec of tags are given (hence the :clear => true option). def taglist=(value) tag(value, {:clear => true}) end I don't know if this is the best way of doing it, but the quickest way in my case at least. In my screens I am only using a text box anyway, so this looked good to me. HTH, Ronny On 9/5/05, automat_svet@eml.cc <automat_svet@eml.cc> wrote:> > Hi all, > I'm trying to setup act_as_taggable and I really need an advice/ > example on how to setup the controller for new articles, new articles > are saved but tags_articles and tags tables remain untouched... > on development.log i can see this: > SQL (0.000850) INSERT INTO tags (`name`, `desc`) VALUES('', NULL) > so.. I think I'm making some trivial error but... till now I can't > figure out which.. > > thanks > > automat_svet > > Il giorno 03/set/05, alle ore 17:58, Demetrius Nunes ha scritto: > > > Hi folks, > > > > Thanks to the community feedback on the 1st version, I've come up > > with a much improved version of the acts_as_taggable mixin. > > > > There´s some piece of the action here: > > http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- > > with-rails > > > > Cheers > > Dema > > -- > > http://dema.ruby.com.br - Rails from a .NET perspective > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
BTW: The edit: section above is code that in my case is in the _form.rhtml file. The show: code is in the show.rhtml file... Ronny On 9/5/05, Ronny Hanssen <super.ronny@gmail.com> wrote:> > You need to list the tags in the form. Easiest way is a text box. > > show: > <b>Tags:</b> <%=h @item.taglist %> > > edit: > <p><label for="article_taglist">Tags (space separated)</label><br/> > <%= text_field 'article', 'taglist' %></p> > > NB: The code above won't work unless you patch the taggable.rb file, as > specified here: > Insert these two methods on line 207: > > # Simplifies IO with forms for the tagging. > # Good for displaying in a form (in a text box) > def taglist > tag_names.join(" ") > end > > # Simplifies IO with forms for the tagging > # It is used for bulk updates from a form, and expects that the > # full spec of tags are given (hence the :clear => true option). > def taglist=(value) > tag(value, {:clear => true}) > end > > > I don't know if this is the best way of doing it, but the quickest way in > my case at least. In my screens I am only using a text box anyway, so this > looked good to me. > > HTH, > Ronny > > > On 9/5/05, automat_svet@eml.cc <automat_svet@eml.cc> wrote: > > > > Hi all, > > I'm trying to setup act_as_taggable and I really need an advice/ > > example on how to setup the controller for new articles, new articles > > are saved but tags_articles and tags tables remain untouched... > > on development.log i can see this: > > SQL (0.000850) INSERT INTO tags (`name`, `desc`) VALUES('', NULL) > > so.. I think I'm making some trivial error but... till now I can't > > figure out which.. > > > > thanks > > > > automat_svet > > > > Il giorno 03/set/05, alle ore 17:58, Demetrius Nunes ha scritto: > > > > > Hi folks, > > > > > > Thanks to the community feedback on the 1st version, I've come up > > > with a much improved version of the acts_as_taggable mixin. > > > > > > There´s some piece of the action here: > > > http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- > > > with-rails > > > > > > Cheers > > > Dema > > > -- > > > http://dema.ruby.com.br - Rails from a .NET perspective > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
All you should need to do is something like this: a = Article.find_first a.tag("cool extension") a.save The problem you describe sounds like you have an older version of taggable.rb and are trying to save a new object. Either save the object first, then apply the tags, and then save again; or, download the newest version of taggable. HTH --Dave. On 5-Sep-05, at 10:42 AM, automat_svet-ZKwmMI9HCDA@public.gmane.org wrote:> Hi all, > I''m trying to setup act_as_taggable and I really need an advice/ > example on how to setup the controller for new articles, new > articles are saved but tags_articles and tags tables remain > untouched... > on development.log i can see this: > SQL (0.000850) INSERT INTO tags (`name`, `desc`) VALUES('''', NULL) > so.. I think I''m making some trivial error but... till now I can''t > figure out which.. > > thanks > > automat_svet > > Il giorno 03/set/05, alle ore 17:58, Demetrius Nunes ha scritto: > > >> Hi folks, >> >> Thanks to the community feedback on the 1st version, I''ve come up >> with a much improved version of the acts_as_taggable mixin. >> >> There´s some piece of the action here: >> http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- >> with-rails >> >> Cheers >> Dema >> -- >> http://dema.ruby.com.br - Rails from a .NET perspective >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
wow Ronny, this completely solved my problem! thank you very much... automat> You need to list the tags in the form. Easiest way is a text box. > > show: > <b>Tags:</b> <%=h @item.taglist %> > > edit: > <p><label for="article_taglist">Tags (space separated)</label><br/> > <%= text_field ''article'', ''taglist'' %></p> > > NB: The code above won''t work unless you patch the taggable.rb > file, as specified here: > Insert these two methods on line 207: > > # Simplifies IO with forms for the tagging. > # Good for displaying in a form (in a text box) > def taglist > tag_names.join(" ") > end > > # Simplifies IO with forms for the tagging > # It is used for bulk updates from a form, and expects that > the > # full spec of tags are given (hence the :clear => true > option). > def taglist=(value) > tag(value, {:clear => true}) > end > > > I don''t know if this is the best way of doing it, but the quickest > way in my case at least. In my screens I am only using a text box > anyway, so this looked good to me. > > HTH, > Ronny > > > On 9/5/05, automat_svet-ZKwmMI9HCDA@public.gmane.org <automat_svet-ZKwmMI9HCDA@public.gmane.org> wrote: > Hi all, > I''m trying to setup act_as_taggable and I really need an advice/ > example on how to setup the controller for new articles, new articles > are saved but tags_articles and tags tables remain untouched... > on development.log i can see this: > SQL (0.000850) INSERT INTO tags (`name`, `desc`) VALUES('''', NULL) > so.. I think I''m making some trivial error but... till now I can''t > figure out which.. > > thanks > > automat_svet > > Il giorno 03/set/05, alle ore 17:58, Demetrius Nunes ha scritto: > > > Hi folks, > > > > Thanks to the community feedback on the 1st version, I''ve come up > > with a much improved version of the acts_as_taggable mixin. > > > > There´s some piece of the action here: > > http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids- > > with-rails > > > > Cheers > > Dema > > -- > > http://dema.ruby.com.br - Rails from a .NET perspective > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails