这几天研究一个 ROR 项目的 DEMO,从搭建环境到运行代码,遇到了许多问题,查资料,发帖,像是闯关,一步步到了现在。临近成功,在 rake 数据迁移时遇到了一个问题,卡在这里很长时候了。感谢大家对我帖子的回复!帮助了我许多!下面我再把我遇到的问题描述一下,现在这里感谢大家了!
问题:
仔细看了一下,才发现这个项目里有 Spring,一直以为 spring 都是 Java 的 framework 框架,看到 ruby 里也在使用。这里是 spring ruby 的 github(https://github.com/rails/spring) 这里是关于 spring rake 的部分的描述
Runs a rake task. Rake tasks run in the development environment by default. You can change this on the fly by using the RAILS_ENV environment variable. The environment is also configurable with the Spring::Commands::Rake.environment_matchers hash. This has sensible defaults, but if you need to match a specific task to a specific environment, you'd do it like this:
Spring::Commands::Rake.environment_matchers["perf_test"] = "test" Spring::Commands::Rake.environment_matchers[/^perf/] = "test"
rake
with no argumentsSpring::Commands::Rake.environment_matchers[:default] = "development"
然后根据描述,运行命令
`` rake db:migrate RAILS_ENV=production ``
报错了,内容如下:
/home/chenx/iceage-master/config/initializers/load_regions.rb:1:in read': No such file or directory @ rb_sysopen - config/regions.yml (Errno::ENOENT)
from /home/chenx/iceage-master/config/initializers/load_regions.rb:1:in
'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in load'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in
block in load'
. . . . . . .
大概意思是说 ``load_regions.rb ``找不到文件``config/regions.yml ``
打开 ``load_regions.rb ``内容如下:
REGIONS = HashWithIndifferentAccess.new(YAML.load(File.read('config/regions.yml')))
想了想,改为以下内容,把``config/regions.yml ``的相对路径补全
REGIONS = HashWithIndifferentAccess.new(YAML.load(File.read('../config/regions.yml')))
又报错了:
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:492:in load_missing_constant': Circular dependency detected while autoloading constant AdminUser (RuntimeError)
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in
const_missing'
from /home/chenx/iceage-master/app/admin/admin_user.rb:1:in <top (required)>'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:457:in
load'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:457:in `block in load_file'
. . . . . .
麻烦大家帮忙看一下这个什么问题?