我哪里错了? “Sinatra的未定义方法'应用程序':模块”Sinatra / Passenger / Apache

时间:2010-06-07 14:01:30

标签: ruby apache sinatra passenger

我正试图让我的第一个Sinatra应用程序开始,但我从Passenger获得了一个错误页面:

undefined method `application' for Sinatra:Module

这是我的Rackup文件:

require 'rubygems'
require 'sinatra'
set :env,  :production
disable :run
require 'app'
run Sinatra.application

应用程序本身:

#!/usr/bin/env ruby

require 'rubygems'
require 'sinatra'
require 'haml'

get '/' do
  haml :index
end

get '/hello/:name' do |name|
  @name = name
  haml :hello
end

get '/goodbye/:name' do |name|
  haml :goodbye, :locals => {:name => name}
end

__END__

@@layout
%html
  %head
    %title hello.dev
  %body
    =yield

@@index
#header
  %h1 hello.dev
#content
  %p
    This is a test...

@@hello
%h1= "Hello #{@name}!"

@@goodbye
%h1= "Goodbye #{name}!"

我哪里错了?

1 个答案:

答案 0 :(得分:5)

这是我的 config.ru

require 'application'

set :run, false
set :environment, :production

FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new("log/sinatra.log", "a")
$stdout.reopen(log)
$stderr.reopen(log)

run Sinatra::Application

此外,我的应用代码位于 application.rb