开发者

Installing and using acts-as-taggable-on

This is going to be a really dumb question, I just know it, but I'm going to ask anyways because it's driving me crazy.

How do I get acts-as-taggable-o开发者_如何转开发n to work?

I installed it as a gem with gem install acts-as-taggable-on because I can't ever seem to get installing plugins to work, but that's a whole other batch of questions that are all probably really dumb. Anyways, no problems there, it installed correctly.

I did ruby script/generate acts_as_taggable_on_migration and rake db:migrate, again no problems.

I added acts_as_taggable to the model I want to use tags with, started up the server and then loaded the index for the model just to see if what I've got so far is working and got the following error: undefined local variable or method `acts_as_taggable' for #.

I figure that just means I need to do something like require 'acts-as-taggable-on' to my model's file because that's typically what's necessary for gems. So I did that hit refresh and got uninitialized constant ActiveRecord::VERSION. I'm not even going to pretend to begin to know what that means went wrong.

Did I go wrong somewhere or there something else I need to do. The installation instructions seem to me like they just assume you generally know what you're doing and don't even begin to explain what to do when things go wrong.


Did you try to define your gem dependencies in config/environment.rb (Rails 2.3):

Rails::Initializer.run do |config|
  #...
  config.gem 'acts-as-taggable-on'
  #...
end

Or in Gemfile for Rails 3 or if you use already Bundler with rails 2.3:

gem 'acts-as-taggable-on'

This should make the require 'acts-as-taggable-on' unnecessary


Maybe following the installation here can help.

For example you don't need to:

require 'acts-as-taggable-on'

but:

class User < ActiveRecord::Base
  acts_as_taggable
end

Otherwise you need to post more details about the error.


I installed acts-as-taggable-on for my app through github. If you want to try that method instead of the gem, you can read my this post that explains my experience: http://blog.mediummassage.com/2010/04/27/creating-categories-in-the-store-with-tags/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜