在 rails 3 中是 rails s
调用 bundler,这样你就不需要做 bundle exec rails s
或者是 bundle exec
需要运行 rails s
在您的应用程序 Gemfile 环境中?
更新
据了解,bundle exec
由于不同的 rake 版本,应该在 rake 任务之前使用。见 http://railsapps.github.com/installing-rails-3-1.html更多细节。这个问题是关于 rails 脚本的,比如:
rails s
rails server
rails c
rails console
^应该
bundle exec
在这些 rails 脚本之前使用,还是由 rails 命令调用 bundler?
最佳答案
您应该在 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.
引用自:https://www.wyeworks.com/blog/2011/12/27/bundle-exec-rails-executes-bundler-setup-3-times/
关于ruby-on-rails-3 - rails s 或 bundle exec rails s,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11617085/