0

我在尝试启动我的 Rails 项目时遇到了一个重大问题。我正在使用 rails 4.0.0 项目并尝试在 Rails 3.2.6 系统上运行它。我的工作环境使用 Rails 3.2.6 环境,而我在家工作的系统(mac mini)使用 rails 4。从那以后,我开始使用我的 Linux 笔记本电脑,它像我的雇主一样使用 Rails 3.2.6。

这是我的错误跟踪:

ironmantis7x@ironscribe5:~/RoR_projects/mock_devices2$ rails server
=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/actionpack-3.2.6/lib/action_dispatch/routing/mapper.rb:260:in `merge': can't convert String into Hash (TypeError)
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/actionpack-3.2.6/lib/action_dispatch/routing/mapper.rb:260:in `root'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/actionpack-3.2.6/lib/action_dispatch/routing/mapper.rb:1317:in `root'
        from /home/ironmantis7x/RoR_projects/mock_devices2/config/routes.rb:10:in `block in <top (required)>'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:260:in `draw'
        from /home/ironmantis7x/RoR_projects/mock_devices2/config/routes.rb:1:in `<top (required)>'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `block in load'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:40:in `each'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:40:in `load_paths'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:16:in `reload!'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:26:in `block in updater'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/activesupport-3.2.6/lib/active_support/file_update_checker.rb:78:in `call'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/activesupport-3.2.6/lib/active_support/file_update_checker.rb:78:in `execute'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:27:in `updater'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /home/ironmantis7x/RoR_projects/mock_devices2/config/environment.rb:5:in `<top (required)>'
        from /home/ironmantis7x/RoR_projects/mock_devices2/config.ru:4:in `require'
        from /home/ironmantis7x/RoR_projects/mock_devices2/config.ru:4:in `block in <main>'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
        from /home/ironmantis7x/RoR_projects/mock_devices2/config.ru:1:in `new'
        from /home/ironmantis7x/RoR_projects/mock_devices2/config.ru:1:in `<main>'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/commands/server.rb:46:in `app'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/commands/server.rb:70:in `start'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/commands.rb:55:in `block in <top (required)>'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
        from /home/ironmantis7x/.rvm/gems/ruby-1.9.3-p448@rails_testbed1/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
ironmantis7x@ironscribe5:~/RoR_projects/mock_devices2$ 

这是我的 environment.rb 文件:

# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
MockDevices2::Application.initialize!

这是我的 boot.rb 文件:

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'thread'

我的宝石清单如下:

actionmailer (3.2.6)
actionpack (3.2.6)
activemodel (3.2.6)
activerecord (3.2.6)
activeresource (3.2.6)
activesupport (3.2.6)
arel (3.0.2)
builder (3.0.4)
bundler (1.3.5)
bundler-unload (1.0.1)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.2)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.3)
i18n (0.6.4)
jbuilder (1.4.2)
journey (1.0.4)
jquery-rails (3.0.1)
json (1.8.0)
mail (2.4.4)
mime-types (1.23)
mini_portile (0.5.0)
multi_json (1.7.7)
nokogiri (1.6.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.6)
railties (3.2.6)
rake (10.1.0)
rdoc (3.12.2)
rubygems-bundler (1.2.0)
rvm (1.11.3.8)
sass (3.2.9)
sass-rails (3.2.6)
sdoc (0.3.20)
sprockets (2.1.3)
sqlite3 (1.3.7)
thor (0.18.1)
tilt (1.4.1)
treetop (1.4.14)
turbolinks (1.2.0)
tzinfo (0.3.37)
uglifier (2.1.1)
4

1 回答 1

4

你能发布你的routes.rb吗?似乎问题出在

from /home/ironmantis7x/RoR_projects/mock_devices2/config/routes.rb:10:in `block in <top (required)>'

这发生在我身上,问题是我使用

root 'welcome#index'

代替

root to: 'welcome#index'

Rails 3 不喜欢这样

于 2013-11-04T11:25:43.323 回答