Sinatra :: ConfigFile,NoMethodError - 未定义的方法

时间:2013-12-22 11:44:11

标签: ruby sinatra

我按照建议完全设置了ConfigFile扩展名(?),但是我收到以下错误:

App 32163 stderr: NoMethodError - undefined method `title' for Testing:Class:

app.rb

# Bundler
require "rubygems"
require "bundler/setup"

# Sinatra
require "sinatra/base"
require "sinatra/config_file"

# Mustache und Markdown
require "mustache/sinatra"
require "rdiscount"


# The app
class Testing < Sinatra::Base
  register Mustache::Sinatra
  register Sinatra::ConfigFile

  require './views/layout'

  config_file './config.yml'

  set :mustache, {
    :views     => './views',
    :templates => './templates'
  }

  get "/" do
    @title = settings.title
    @content = markdown(:content)
    mustache :index
  end
end

config.yml

title: title

有谁能告诉我我做错了什么?

1 个答案:

答案 0 :(得分:1)

您的问题是title: title用作变量而不是字符串。

要解决此问题,请使用title: "title"