无法使用rake和ruby创建数据库

时间:2015-09-08 05:47:48

标签: ruby activerecord rake

我正在使用ruby和sinatra与activerecord和rake(没有rails)。我的db目录中有以下config.yml文件(我省略了生产)。

config.yml

rake aborted!
ActiveRecord::AdapterNotSpecified: 'development' database is not configured. Available: []
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:248:in `resolve_symbol_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:211:in `resolve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:139:in `resolve'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:169:in `spec'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:109:in `create_current'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => db:create
(See full trace by running task with --trace)

当我运行rake db:create或rake db:setup时,我收到以下错误:

# Rakefile

require './app'
require 'sinatra'
require 'active_record'
require 'sinatra/activerecord/rake'
#require 'rake'

Rake文件

source 'https://rubygems.org'


gem "sinatra"
gem "activerecord"
gem "sinatra-activerecord"
gem 'sinatra-flash'
gem 'sinatra-redirect-with-flash'
gem 'rake'

group :development do
 gem 'sqlite3'
 gem "tux"
end

group :production do
 gem 'sqlite3'
end

的Gemfile

TCPBasicClientApp::socketDataArrived()

1 个答案:

答案 0 :(得分:1)

数据库配置应位于config/database.yml,而不是db/config.yml