Reputation: 267190
My gem file looks like:
group :development, :test do
gem 'rspec-rails'
gem 'annotate-models', '1.0.4'
end
I ran 'bundle install
' and it installed the annotate-models bundle.
If I type: annotate
I get a command not found error.
If I type: bundle show annotate
I get a 'could not find gem annotate in the current bundle.
If I type bundle show annotate-models it says it installed in:
/Library/Ruby/Gems/1.8/gems/annotate-models-1.0.4
typing:
annotate-models
doesn't work either.
I'm following along in railstutorial.org and got stuck at this point.
Upvotes: 18
Views: 17501
Reputation: 2759
You can use it for Rails 4, add gem in your gem file gem "annotate", "~> 2.5.0" and run following command
rails g annotate_models:install
instead of
rails g annotate:install
Then run following command to add schema information after model class
bundle exec annotate -p after
or can use following for before
bundle exec annotate -p before
Upvotes: 0
Reputation: 6699
Edit: Better version (using Bundler to install it only for the current project)
gem 'annotate'
to Gemfile$ bundle install
$ bundle exec annotate
Edit2: Seems you have to explicitly specify annotate version for now, so in Gemfile put gem 'annotate', '2.4.1.beta1'
(which is a prereleased beta gem that works with the latest version of activerecord as opposed to specifying the github repo directly)
Edit3: 2.5.0 final is out now, so hopefully no need to force a beta version any more, just getting the latest should work!
Old version (with installing the gem on a system level too):
If running Rails 3 the drill is:
$ sudo gem install annotate
gem 'annotate'
to Gemfile$ bundle install
$ annotate
Upvotes: 34
Reputation: 21
Use
gem 'annotate', '2.4.0'
instead of
gem 'annotate-models', '1.0.4'
It looks like the gem name was changed at RubyGems.org.
Upvotes: 2
Reputation: 543
The most voted answer didn't fully work for me, as I was getting and additional error when follow the proposed solution:
undefined method `namespace' for main:Object (NoMethodError)
I'm including below what worked for me (I'm using Ruby 1.9.2 and Rails 3.1.3 under Ubuntu 11.10):
Install annotate
$ gem install annotate
Modify Gemfile adding the following line
gem 'annotate',
:git => 'git://github.com/jeremyolliver/annotate_models.git',
:branch => 'rake_compatibility'
Install bundle
$ bundle install
Now you can use annotate as follows:
$ bundle exec annotate
Upvotes: 10
Reputation: 2856
For me the answer was this one: http://news.railstutorial.org/model-annotation
Upvotes: 3
Reputation: 1197
You should run the command inside your bundled environment with:
$ bundle exec annotate
Check out the man page for more details.
Upvotes: 10
Reputation: 414
I'm new to this, but I was having this problem doing the rails tutorial, but by adding the gems bin path to the PATH env variable I was able to fix it. (Just like gertas said a few posts above)
First in the command prompt:
gem list -d annotate
and you'll get a result that says something like
: annotate-models (1.0.4)
Author: Dave Thomas
Rubyforge: http://rubyforge.org/projects/annotate-models
Homepage: h'ttp://annotate-models.rubyforge.org
Installed at: C:/ruby192/lib/ruby/gems/1.9.1
the key line is:
Installed at: C:/ruby192/lib/ruby/gems/1.9.1
So in this case add a /bin to that path, For example I used: C:\ruby192\lib\ruby\gems\1.9.1\bin is what you want to add to your PATH environment variable.
To change your PATH environment variable on Vista do the following go to: control panel >> system >> advanced system settings(link on the left). Once the box opens up,click the Advanced tab and then the Environment variables button. Then on the system variables find the PATH variable and click the Edit button. Since paths are separated by semi-colons, add
;C:\ruby192\lib\ruby\gems\1.9.1\bin
At the end of the variable value field.
It should look like `some/path;some_other_path;C:\ruby192\lib\ruby\gems\1.9.1\bin` when you finish
Save it, and close and reopen the command prompt. annotate and rspec started to work for me after that. Good luck.
Upvotes: 3
Reputation: 17145
I think your PATH env variable lacks path to gems bin directory.
I guess it should be: /Library/Ruby/Gems/1.8/bin
Upvotes: 0