当前位置: 动力学知识库 > 问答 > 编程问答 >

Deployed ruby on rails on shared hosting - routing issue

问题描述:

I'm a rails newbie. I'm struggling to get a simple helloworld rails app(no db) working on on shared hosting.

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)

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

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

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

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

Server versions:

Ruby Version : 1.8.7

Gem Version : 1.8.16

Rails is 2.3.14

Steps I took to configure helloWorld app:

  1. Created app using web form http://scifiwear.com/rails_setup.png

  2. cd myapp14

  3. ruby script/generate controller Say hello goodbye

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

5 http://myapp14.scifiwear.com/say/hello NOT HAPPY!

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

Last 4 lines of my routes.rb: (untouched)

# 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

Any suggestions appreciated thanks.

网友答案:

Try the answers given for this previous question : Problems running Ruby on Rails apps on shared hosted server; they might be helpful in this case.

I tried reproducing the same error locally, with rails 2.3.14 and ruby 1.8.7-p371; didn't get the error message. The routes file is similar to what you have.

The log trace is as follows:

=> 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/[email protected]/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/[email protected]/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]

Given that the ruby & rails versions are very old on this hosted server, it might be difficult for you to get help on issues faced with this installation. And you would face difficulty in learning the concepts as well.

My advise would be for you to switch to using the latest version of ruby & rails (and learn about the best practices of web development with rails), by following the excellent & freely available online book by Michael Hartl : Ruby on Rails Tutorial

分享给朋友:
您可能感兴趣的文章:
随机阅读: