Judd Ster
2006-Jan-30 22:17 UTC
[Rails] acts_as_taggable => error: undefined method ''tag''
I get an "undefined method ''tag''" when I try to use the acts_as_taggable. Note that it''s not the issue of bouncing webrick after changing the environment.rb file. (I stumbled on that too... :-( ). I read all the doc I could find (on this site, on http://rails.techno-weenie.net and at http://taggable.rubyforge.org/) but I couldn''t find anything I might be doing wrong. I marked my Item model as "acts_as_taggable" right at the top and in item_controller::create method I''m calling @item.tag method after saving the item. #item.rb class Item < ActiveRecord::Base acts_as_taggable ... #item_controller.rb ... if @item.save @item.reload @item.tag("cool") redirect_to :action => ''show'', :id=> @item.id end ... Any help will be greatly appreciated! Thanks in advance... -- Posted via http://www.ruby-forum.com/.
Judd Ster
2006-Jan-30 23:22 UTC
[Rails] Re: acts_as_taggable => error: undefined method ''tag''
The resolution is very interesting but it has nothing to do with acts_as_taggable. At some point I realized that no changes in the model (item.rb) are picked up by rails. No matter what I tried (I even reboot my machine), rails kept happy with a model file that, at that point, had obvious junk in it. Turns out rails was picking up an older file from a subdirectory of the models directory (i.e. app/models/save/item.rb). I had to change that file name to xitem.rb to convince rails it is not my model file. Looks like a bug in rails to me? Considering this is the first time I loose a few hours to a stupid rails bug after a few months of using it, I guess I can?t complain. But still, it was pretty frustrating :-( Judd Ster wrote:> I get an "undefined method ''tag''" when I try to use the > acts_as_taggable. > > Note that it''s not the issue of bouncing webrick after changing the > environment.rb file. (I stumbled on that too... :-( ). > > I read all the doc I could find (on this site, on > http://rails.techno-weenie.net and at http://taggable.rubyforge.org/) > but I couldn''t find anything I might be doing wrong. > > I marked my Item model as "acts_as_taggable" right at the top and in > item_controller::create method I''m calling @item.tag method after saving > the item. > > #item.rb > class Item < ActiveRecord::Base > acts_as_taggable > ... > > #item_controller.rb > ... > if @item.save > @item.reload > @item.tag("cool") > redirect_to :action => ''show'', :id=> @item.id > end > ... > > Any help will be greatly appreciated! > Thanks in advance...-- Posted via http://www.ruby-forum.com/.