我在Mac OS X + Docker Machine + Docker Compose上开发Rails 4应用程序有相当多的经验,但Rails 5在开发环境中缓存文件(目前使用RC1进行测试)的方式已经发生了变化.
在启动应用程序后docker-compose up,应用程序在开发模式下正常运行.
但是,如果我对控制器或模型进行更改,我可以在应用程序中反映的唯一方法是停止服务器并重新启动它.
所以,当我需要对控制器或模型进行更改时,我的工作流程看起来像这样:
Ctrl + C.docker-compose up.至少可以说,需要做的步骤2-4很烦人,而不是我从Rails 4习惯的.
我更进一步,使用删除指令卸载Spring ,但我仍然得到相同的行为.
我还搜索了我可以找到的config/environments/development.rb与Rails运行时在模型和控制器类上的铁柄有关的任何设置,我找不到任何东西.(我假设它真的想依赖于观察文件系统以便有选择地加载更改,并且从Mac上的更改到VirtualBox没有获取某些东西.)
关于我可以尝试的任何其他想法?或者是否有任何与此更激进的缓存如何工作相关的新设置?
在rails generate新的Rails 4.2项目上运行时,我不断收到错误:
~/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.0/lib/spring/configuration.rb:37:in `pwd': No such file or directory - getcwd (Errno::ENOENT)
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
我最近将Ruby升级到2.5.0.从那以后,我无法正确运行Rails控制台.它要么无限期挂起,要么在几秒钟后向我显示此错误:
before_session hook failed: NoMethodError: undefined method `reject!' for nil:NilClass
完整错误:
Running via Spring preloader in process 6102
Loading development environment (Rails 5.1.4)
before_session hook failed: NoMethodError: undefined method `reject!' for nil:NilClass
Traceback (most recent call last):
/Users/zoro/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': undefined method `reject!' for nil:NilClass (NoMethodError)
Run Code Online (Sandbox Code Playgroud)
如果我DISABLE_SPRING,我可以按预期启动我的控制台.但是,(不确定这是否相关,如果不是 - 我可以单独解决)如果发生任何错误,控制台"崩溃"并将我踢回终端:
?rails console
Loading development environment (Rails 5.1.4)
[1] pry(main)> a
Traceback (most recent call last):
bin/rails: undefined method `[]' for nil:NilClass (NoMethodError)
?
Run Code Online (Sandbox Code Playgroud)
任何有关这方面的帮助将不胜感激.使用rbenv来管理Rubies,并且在其他版本的Ruby上没有此错误.
我目前正在使用Spork with Guard,Rspec和Cucumber.我想转移到Spring,但找不到任何需要更改的文档.
具体来说,我很好奇我是否需要更改我的:
require 'spork'
Spork.prefork do
# ...
end
Spork.each_run do
# ...
end
Run Code Online (Sandbox Code Playgroud)
...有类似的东西:
require 'spring'
Spring.prefork do
# ...
end
Spring.each_run do
# ...
end
Run Code Online (Sandbox Code Playgroud)
但是,我知道没有,Spring.prefork因为文档说的是这样.那么我应该简单地删除引用Spork或者我需要用某些东西替换它们吗?
我正在尝试按照这些说明使用 Google 添加 oauth2 。
我在启动服务器时收到以下错误消息:
Exiting
You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).
This is probably because you generated binstubs with Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve this, upgrade your bundle to the latest Spring version and then run `bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time step necessary to upgrade from 1.0 to …Run Code Online (Sandbox Code Playgroud) ruby-on-rails oauth-2.0 google-oauth rails-spring ruby-on-rails-5
我用
当我开始
$ docker-compose exec web /bin/bash # ssh into the web server
$ bundle exec rails c
Run Code Online (Sandbox Code Playgroud)
我收到以下错误。
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:86:in `each'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:86:in `block in require'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:75:in `each'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:75:in `require'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler.rb:106:in `require'
from /usr/src/app/config/application.rb:7:in `<top (required)>'
from /usr/local/bundle/gems/spring-1.7.2/lib/spring/application.rb:82:in `require'
from /usr/local/bundle/gems/spring-1.7.2/lib/spring/application.rb:82:in `preload'
from /usr/local/bundle/gems/spring-1.7.2/lib/spring/application.rb:143:in `serve'
from /usr/local/bundle/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /usr/local/bundle/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /usr/local/bundle/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /usr/local/bundle/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Run Code Online (Sandbox Code Playgroud)
但是我已经把pqgem 放在了 …