NoMethodError: undefined 方法 'configure' for main:object on sinatra project



所以我正在遵循与辛纳屈:http://mherman.org/blog/2013/06/06/08/designing建立postgres db的这一良好的老式教程 - 与级别的Sinatra-Plus-Postgresql-plus-heroku/

我已经建议设置我的vromentments.rb和耙子文件,如下所示:

configure :development do
  set :database, "sqlite:///dev.db"
  set :show_exceptions, true
end
configure :production do
  db = URI.parse(ENV["DATABASE_URL"] || 'postgres:///localhost/mydb')
  ActiveRecord::Base.establish_connection(
    :adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
    :host => db.host,
    :username => db.user,
    :password => db.password,
    :database => db.path[1..-1],
    :encoding => 'utf8'
  )
end

和:

require './app_name'
require 'sinatra/activerecord/rake'

当我尝试使用:

创建迁移时
rake db:create_migration NAME=create_applicants

它与此错误:

NoMethodError: undefined method `configure' for main:Object
/Users/harxy/Projects/bridgey/environments.rb:1:in `<top (required)>'

关于这里可能出问题的任何想法?

谢谢。

根据杰克·布拉肯(Jack Bracken)的上述评论,您在环境中需要 require 'sinatra'才能工作。

相关内容

最新更新