我是ruby和rails的新手。我已经通过了轨道僵尸教程和其他几个。
我使用网络主机上的工具生成了一个默认的rails应用程序。
我将rails连接到数据库,并能够显示一个包含其中值的页面
从我所有的搜索来看,我相信只要将我的视图文件命名为*.html.erb就足以使它们以mime类型呈现html
问题是页面显示的内容类型为:text/plain
这是我的
config/routes.rb
ActionController::Routing::Routes.draw do |map|
map.resources :enrollapplications
end
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
end
app/controllers/enrolllapplications_controller.rb
class EnrollapplicationsController < ApplicationController
def show
@enrollapp = Enrollapplication.find(params[:id])
end
end
app/views/layouts/application.html.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Enrollment Application</title>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>
app/views/enrollplications/show.html.erb
<h3>show stuff</h3>
<h1><%= @enrollapp.firstName %></h1>
curl-I example.com/Application/enrollapplications/1
HTTP/1.1 200 OK
Date: Sun, 28 Jul 2013 17:37:36 GMT
Content-Type: text/plain
可以随意指出并嘲笑我的错误。
我的主机的Linux管理员说他们正在运行Mongrel的一个版本,这是一个已知的错误。
他在我的/config/initializers中放了一个更新版本的mongrel.rb,解决了这个问题。