【问题标题】:Where am I going wrong? "undefined method 'application' for Sinatra:Module" Sinatra/Passenger/Apache我哪里错了? “Sinatra:Module 的未定义方法‘应用程序’” Sinatra/Passenger/Apache
【发布时间】:2010-06-07 14:01:29
【问题描述】:

我正在尝试启动我的第一个 Sinatra 应用程序,但从乘客那里得到一个错误页面:

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}!"

我哪里错了?

【问题讨论】:

    标签: ruby apache sinatra passenger


    【解决方案1】:

    这是我的 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

    【讨论】:

      猜你喜欢
      • 2015-02-15
      • 2011-03-23
      • 1970-01-01
      • 2011-09-17
      • 1970-01-01
      • 1970-01-01
      • 2010-12-22
      • 1970-01-01
      • 2014-03-01
      相关资源
      最近更新 更多