注释命令不起作用,将其添加到我的 gemfile 中
我的 gem 文件如下所示:
group :development, :test do
gem 'rspec-rails'
gem 'annotate-models', '1.0.4'
end
我运行了“bundle install
”并安装了 annotate-models 包。
如果我输入:annotate
,我会收到命令未找到错误。
如果我输入:bundle show annotate
,我会收到“在当前包中找不到 gem 注释”的信息。
如果我输入bundle show annotate-models,它会说它安装在:
/Library/Ruby/Gems/1.8/gems/annotate-models-1.0.4
输入:
annotate-models
也不起作用。
我正在跟踪railstutorial.org并在这一点上陷入困境。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
编辑:更好的版本(使用 Bundler 仅为当前项目安装它)
gem 'annotate'
添加到 Gemfile$ bundle install
$ bundle exec annotate< /code>
Edit2:似乎您现在必须显式指定注释版本,因此在 Gemfile 中放入
gem 'annotate', '2.4.1.beta1'
(这是一个预发布的 beta gem,可与最新版本的 activerecord 而不是直接指定 github 存储库)Edit3:2.5.0 Final 现已发布,所以希望不再需要强制使用 beta 版本,只需获取最新版本就可以了!
旧版本(也在系统级别安装 gem):
如果运行 Rails 3,则练习是:
$ sudo gem install annotate
gem 'annotate'
添加到 Gemfile$bundle install
$annotate
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
您应该在捆绑环境中运行该命令:
查看 手册页更多细节。
You should run the command inside your bundled environment with:
Check out the man page for more details.
投票最多的答案并不完全适合我,因为在遵循建议的解决方案时,我遇到了额外的错误:
我在下面包含了对我有用的内容(我在 Ubuntu 下使用 Ruby 1.9.2 和 Rails 3.1.3 11.10):
安装注释
修改 Gemfile 添加以下行
安装包
现在您可以按如下方式使用注释:
The most voted answer didn't fully work for me, as I was getting and additional error when follow the proposed solution:
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
Modify Gemfile adding the following line
Install bundle
Now you can use annotate as follows:
我对此很陌生,但我在执行 Rails 教程时遇到了这个问题,但通过将 gems bin 路径添加到 PATH 环境变量,我能够修复它。 (就像 gertas 上面说的几篇文章一样)
首先在命令提示符中:
你会得到一个类似的结果
关键行是:
安装在:C:/ruby192/lib/ruby/gems/1.9.1
所以在这种情况下将 /bin 添加到该路径,例如我使用: C:\ruby192\lib\ruby\gems\1.9.1\bin 是你要添加到 PATH 环境变量中的内容。
要在 Vista 上更改 PATH 环境变量,请转至:控制面板 >>系统>>高级系统设置(左侧链接)。该框打开后,单击“高级”选项卡,然后单击“环境变量”按钮。然后在系统变量中找到 PATH 变量并单击编辑按钮。由于路径是用分号分隔的,所以添加
;C:\ruby192\lib\ruby\gems\1.9.1\bin
在变量值字段的末尾。
它应该看起来像
`一些/路径;some_other_path;C:\ruby192\lib\ruby\gems\1.9.1\bin`
完成后
保存,然后关闭并重新打开命令提示符。此后,annotate 和 rspec 开始为我工作。祝你好运。
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:
and you'll get a result that says something like
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.
对我来说,答案是这样的:
http://news.railstutorial.org/model-annotation
For me the answer was this one:
http://news.railstutorial.org/model-annotation
使用
代替
RubyGems.org 上的 gem 名称似乎已更改。
Use
instead of
It looks like the gem name was changed at RubyGems.org.
我认为您的 PATH 环境变量缺少 gems bin 目录的路径。
我想应该是:
/Library/Ruby/Gems/1.8/bin
I think your PATH env variable lacks path to gems bin directory.
I guess it should be:
/Library/Ruby/Gems/1.8/bin
您可以将它用于Rails 4,在gem文件gem“annotate”,“〜> 2.5.0”中添加gem并运行以下命令
而不是
然后运行以下命令以在模型类之后添加模式信息
,或者可以在之前使用以下命令
You can use it for Rails 4, add gem in your gem file gem "annotate", "~> 2.5.0" and run following command
instead of
Then run following command to add schema information after model class
or can use following for before
如果
bundle exec annotate
不起作用,请尝试:If
bundle exec annotate
doesn't work, try: