在共享主机上的rails上部署ruby - 路由问题

时间:2012-12-20 05:45:10

标签: ruby-on-rails shared-hosting

我是铁杆新手。我正在努力让一个简单的helloworld rails应用程序(没有数据库)在共享主机上工作。

development.log

Processing ApplicationController#index (for 122.61.170.222 at 2012-12-17 17:46:09) [GET]

ActionController::RoutingError (No route matches "/Say/hello" with {:method=>:get}):


Rendering rescues/layout (not_found)

我的导轨设置:http://scifiwear.com/rails_setup.png

rails setup http://scifiwear.com/rails_setup.png

我的子域名设置:http://scifiwear.com/subdomain.png

subdomain setup http://scifiwear.com/subdomain.png

服务器版本:

Ruby版本:1.8.7 宝石版:1.8.16 Rails是2.3.14

我用来配置helloWorld app的步骤:

  1. 使用网络表单http://scifiwear.com/rails_setup.png

  2. 创建应用
  3. cd myapp14

  4. ruby​​脚本/生成控制器说再见

  5. http://myapp14.scifiwear.com/ HAPPY!

  6. 5 http://myapp14.scifiwear.com/say/hello不快乐!

    mongrel.log:

    Mon Dec 17 17:46:09 -0600 2012: Error calling Dispatcher.dispatch #<NoMethodError: You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.split>
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/cgi_process.rb:52:in `dispatch_cgi'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/dispatcher.rb:27:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/bin/mongrel_rails:19:in `load'
    /usr/bin/mongrel_rails:19
    

    我的routes的最后4行.rb :(未触动)

    # consider removing or commenting them out if you're using named routes and resources.
    
    map.connect ':controller/:action/:id'
    
    map.connect ':controller/:action/:id.:format'
    
    end
    

    任何建议表示感谢。

1 个答案:

答案 0 :(得分:0)

尝试上一个问题的答案:Problems running Ruby on Rails apps on shared hosted server;在这种情况下,他们可能会有帮助。

我尝试使用rails 2.3.14ruby 1.8.7-p371在本地重现相同的错误;没有收到错误消息。路线文件与您拥有的类似。

日志跟踪如下:

=> Booting Mongrel
=> Rails 2.3.14 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Users/hallelujah/.rvm/gems/ruby-1.8.7-p371@hallelujah/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21.
NOTE: Gem::SourceIndex#initialize is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#initialize called from /Users/hallelujah/.rvm/gems/ruby-1.8.7-p371@hallelujah/gems/rails-2.3.14/lib/rails/vendor_gem_source_index.rb:100.
=> Call with -d to detach
=> Ctrl-C to shutdown server


Processing SayController#hello (for 127.0.0.1 at 2012-12-20 15:52:23) [GET]
Rendering say/hello
Completed in 35ms (View: 34, DB: 0) | 200 OK [http://localhost/say/hello]

鉴于ruby&amp; rails托管服务器上的rails版本非常陈旧,您可能很难获得有关此安装所面临问题的帮助。而且你也会在学习这些概念方面遇到困难。

我的建议是让您切换到使用最新版本的ruby&amp;通过遵循优秀的&amp; amp;轨道(并了解使用rails进行Web开发的最佳实践) Michael Hartl免费提供的在线图书:Ruby on Rails Tutorial