rails nut
2006-Jan-20 11:28 UTC
[Rails] HELP: acts_as_taggable problem with :clear => true
I''ve got the basics of acts_as_taggable going, but I now want to use :clear => true on the tags method, because the tags I''m supplying as parameters are the complete set of tags for the item, not additions to existing tags. Problem is, that gives me a nasty SQL error ... Unknown column ''id'' in ''where clause'': UPDATE items_tags SET item_id = NULL WHERE (item_id = 2 AND id IN (NULL,NULL,NULL,NULL,NULL,NULL,NULL)) Any ideas ? My call to tags (in update method in controller) is like this @item.tag(params[:tags], :clear => true ) Acts_as_taggable is invoked like this acts_as_taggable :join_class_name => ''ItemTag'', :join_table => ''items_tags'' i.e. my link table and join_class follow the usual rails conventions, not the usual acts_as_taggable conventions. Thanks in advance for any help, Andy -- Posted via http://www.ruby-forum.com/.
Duane Johnson
2006-Jan-20 16:04 UTC
[Rails] HELP: acts_as_taggable problem with :clear => true
On Jan 20, 2006, at 5:05 AM, rails nut wrote:> I''ve got the basics of acts_as_taggable going, but I now want to use > :clear => true on the tags method, because the tags I''m supplying as > parameters are the complete set of tags for the item, not additions to > existing tags. > > Problem is, that gives me a nasty SQL error ... > > Unknown column ''id'' in ''where clause'': UPDATE items_tags SET item_id > NULL WHERE (item_id = 2 AND id IN > (NULL,NULL,NULL,NULL,NULL,NULL,NULL)) > > Any ideas ? > > My call to tags (in update method in controller) is like this > > @item.tag(params[:tags], :clear => true ) > > Acts_as_taggable is invoked like this > > acts_as_taggable :join_class_name => ''ItemTag'', :join_table => > ''items_tags'' > > i.e. my link table and join_class follow the usual rails conventions, > not the usual acts_as_taggable conventions. > > Thanks in advance for any help, > > Andy >I''m not totally sure what''s going on here... but since it''s looking for an ''id'' column in the join table, I wonder if acts_as_taggable expects there to be an ''id'' column when you specify a join_class_name? That would make sense, I think, since join tables normally do not need an id column, unless there''s an ActiveRecord class that maps to it. Duane Johnson (canadaduane) http://blog.inquirylabs.com/
rails nut
2006-Jan-20 16:34 UTC
[Rails] Re: HELP: acts_as_taggable problem with :clear => true
Duane Johnson wrote:> > I''m not totally sure what''s going on here... but since it''s looking > for an ''id'' column in the join table, I wonder if acts_as_taggable > expects there to be an ''id'' column when you specify a > join_class_name? That would make sense, I think, since join tables > normally do not need an id column, unless there''s an ActiveRecord > class that maps to it. > >Problem is that it all works pretty well (no hard errors) as it is so long as I DON''T specify :clear => true ... that makes me think I have the table definitions right. Andy -- Posted via http://www.ruby-forum.com/.
Kevin
2006-Jan-20 17:40 UTC
[Rails] Re: HELP: acts_as_taggable problem with :clear => true
Make sur eyou join table has no id field. I had the same problem when I used a migration and that auto-magically created the id field for me, hence updates fail. rails nut wrote:> Duane Johnson wrote: >> >> I''m not totally sure what''s going on here... but since it''s looking >> for an ''id'' column in the join table, I wonder if acts_as_taggable >> expects there to be an ''id'' column when you specify a >> join_class_name? That would make sense, I think, since join tables >> normally do not need an id column, unless there''s an ActiveRecord >> class that maps to it. >> >> > > Problem is that it all works pretty well (no hard errors) as it is so > long as I DON''T specify :clear => true ... that makes me think I have > the table definitions right. > > Andy-- Posted via http://www.ruby-forum.com/.
rails nut
2006-Jan-20 18:10 UTC
[Rails] Re: HELP: acts_as_taggable problem with :clear => true
Kevin wrote:> Make sur eyou join table has no id field. I had the same problem when I > used a migration and that auto-magically created the id field for me, > hence updates fail. >That''s not it. My development database (and test too) has just two columns, item_id and tag_id. That''s correct surely ? -- Posted via http://www.ruby-forum.com/.
Chris Hall
2006-Jan-20 18:23 UTC
[Rails] Re: HELP: acts_as_taggable problem with :clear => true
then get rid of the :join_class_name => ''ItemTag'' thats used if you have a model for your join table...you clearly don''t have one if your join table just has the two columns from the rdoc for acts_as_taggable: "You can also use full join models if you want to take advantage of ActiveRecord <http://taggable.rubyforge.org/classes/ActiveRecord.html>?s callbacks, timestamping, inheritance and other features on the join records as well. For that, you use the +:join_class_name+ option. In this case, the join table must have a primary key." so all you should need is acts_as_taggable :join_table => ''items_tags'' On 1/20/06, rails nut <rails_nut@hotpop.com> wrote:> > Kevin wrote: > > Make sur eyou join table has no id field. I had the same problem when I > > used a migration and that auto-magically created the id field for me, > > hence updates fail. > > > > That''s not it. My development database (and test too) has just two > columns, item_id and tag_id. That''s correct surely ? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060120/3ff491fc/attachment.html
rails nut
2006-Jan-20 18:40 UTC
[Rails] Re: Re: HELP: acts_as_taggable problem with :clear => true
Chris Hall wrote:> then get rid of the > > :join_class_name => ''ItemTag'' > > thats used if you have a model for your join table...you clearly don''t > have > one if your join table just has the two columns > > [snip] > > so all you should need is > > acts_as_taggable :join_table => ''items_tags''That''s cracked it, thanks. I obviously mis-read the docs. Andy -- Posted via http://www.ruby-forum.com/.