ruby-on-rails-3 – rails s或bundle exec rails s

前端之家收集整理的这篇文章主要介绍了ruby-on-rails-3 – rails s或bundle exec rails s前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在rails 3中,rails会调用bundler,这样你就不需要在你的应用程序Gemfile环境中运行bundle exec rails或者运行rails所需的bundle exec吗?

更新
据了解,由于rake版本不同,应该在rake任务之前使用bundle exec.有关详细信息,请参见http://railsapps.github.com/installing-rails-3-1.html.这个问题是关于rails脚本的,比如:

rails s
rails server
rails c
rails console

^应该在这些rails脚本之前使用bundle exec,还是rails命令调用bundle?

解决方法

你应该在Rail> = 3.1中得到这种行为,但是你需要小心,因为你可能正在使用旧版本的rake:

It’s good practice to use the command bundle exec rake instead of rake
so you’ll use the version of Rake specified in your gemfile (or a
dependency specified in the Gemfile.lock file) instead of the default
version. For example,instead of rake db:migrate,run bundle exec rake
db:migrate.

What You Need to Know: Make sure you are using Rake 0.9.2.2 (or newer)
with gem update rake before installing Rails 3.1. And use bundle exec
rake instead of rake.

引用自:http://railsapps.github.com/installing-rails-3-1.html

看起来与rails命令相反:

don’t run bundle exec before rails command,rails already checks the
presence of Bundler through the Gemfile and sets up everything
according to it without the overhead of bundle exec. rails command is
the only exception to the rule.

引自:http://blog.wyeworks.com/2011/12/27/bundle-exec-rails-executes-bundler-setup-3-times

原文链接:https://www.f2er.com/ruby/264538.html

猜你在找的Ruby相关文章