Ruby on Rails在Ubuntu上的新安装,让新应用程序工作的问题(TypeError)!

时间:2011-02-23 18:13:28

标签: ruby-on-rails ruby-on-rails-3 ubuntu

刚刚在Ubuntu 10.10上安装了RoR并创建了一个新应用程序,我得到了欢迎页面,但是当我创建一个简单的索引页面时,我得到了TypeError。这就是我所做的:

按照https://help.ubuntu.com/community/RubyOnRails

提供的说明操作

Eveything在安装过程中看起来很好没有错误。我选择使用内置的Web服务器来保持简单。

我使用以下方法创建了一个新应用:

/var/www/$ rails new mynewapp

并在终端启动了网络服务器:

/var/www/mynewapp/script$ rails server
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-02-22 17:14:09] INFO  WEBrick 1.3.1
[2011-02-22 17:14:09] INFO  ruby 1.8.7 (2010-06-23) [i686-linux]
[2011-02-22 17:14:24] INFO  WEBrick::HTTPServer#start: pid=10120 port=3000

我得到了欢迎页面。然后我按照教程(http://guides.rubyonrails.org/getting_started.html)创建了我的索引页面:

/var/www/mynewapp$ rails generate controller home index

然后我编辑了newlly创建的mynewapp / views / home / index.html.erb以添加一些HTML。然后我编辑了mynewapp / config / routes.rb:

Blog::Application.routes.draw do

  #...
  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  root :to => "home#index"

现在,当我浏览到localhost:3000而不是欢迎屏幕时,我在浏览器上收到以下错误:

类型错误

无法将Fixnum转换为String

Rails.root:/ var / www / mynewapp

,这会出现在终端中:

Started GET "/" for 127.0.0.1 at Wed Feb 23 12:23:17 -0500 2011

TypeError (can't convert Fixnum into String):


Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.1ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (6.5ms)

你知道我做错了什么吗? THX

2 个答案:

答案 0 :(得分:1)

好像有一些数据库的三件套。你可以运行“rake db:migrate --trace”并发布结果,如果你还有这样的问题吗?

答案 1 :(得分:0)

您是否将数据库密码设置为纯数字,例如“111111”?我的猜测我应该把它变成非数字的,比如“abcdef”,它有效!

与此类似:Can't convert Fixnum into String - Devise/sessions Controller issue