【发布时间】:2016-11-10 05:57:26
【问题描述】:
首先,我真的很抱歉,因为我还是新手。
我试图按照以下网站上的说明安装 Fat Free CRM:
http://www.blogdugeek.fr/crm-installation-fat-free-crm-debian-squeeze/
http://guides.fatfreecrm.com/Setup-Linux-or-Mac-OS.html
按照说明进行操作时,我遇到了一些错误并解决了一些问题。但是,在执行此命令时:
RAILS_ENV=production rake db:create db:migrate crm:settings:load
我被困在这个命令行中,下面是我一直遇到的以下错误:
rake aborted!
NoMethodError: undefined method `each' for #<String:0x00000003a27a58>
/usr/local/rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:150:in `resolve_all'
/usr/local/rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:69:in `resolve'
/usr/local/rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/core.rb:46:in `configurations='
/usr/local/rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/railties/databases.rake:5:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:create => db:load_config
(See full trace by running task with --trace)
在搜索更多相关问题时,我找到了一些,但仍然没有用。
另外,这里有一些可能需要的数据:
Ruby 版本
ruby 2.2.4p230(2015-12-16 修订版 53155)[x86_64-linux]
Rails 版本
Rails 4.2.6
这是错误行
connection_specification.rb
def resolve(config)
if config
resolve_connection config
elsif env = ActiveRecord::ConnectionHandling::RAILS_ENV.call
resolve_symbol_connection env.to_sym
else
raise AdapterNotSpecified
end
end
# Expands each key in @configurations hash into fully resolved hash
def resolve_all
config = configurations.dup
config.each do |key, value| <---- Error line
config[key] = resolve(value) if value
end
config
end
connection_handling.rb
class MergeAndResolveDefaultUrlConfig # :nodoc:
def initialize(raw_configurations)
@raw_config = raw_configurations.dup
@env = DEFAULT_ENV.call.to_s
end
# Returns fully resolved connection hashes.
# Merges connection information from `ENV['DATABASE_URL']` if available.
def resolve
Error line ----> ConnectionAdapters::ConnectionSpecification::Resolver.new(config).resolve_all
end
private
def config
@raw_config.dup.tap do |cfg|
if url = ENV['DATABASE_URL']
cfg[@env] ||= {}
cfg[@env]["url"] ||= url
end
end
end
core.rb
def self.configurations=(config)
Error line ---> @@configurations = ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig.new(config).resolve
end
self.configurations = {}
# Returns fully resolved configurations hash
def self.configurations
@@configurations
end
databases.rake
db_namespace = namespace :db do task :load_config do
Error line ----> ActiveRecord::Base.configurations = ActiveRecord::Tasks::DatabaseTasks.database_configuration || {}
ActiveRecord::Migrator.migrations_paths = ActiveRecord::Tasks::DatabaseTasks.migrations_paths
这是 config/database.yml 文件。
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
#------------------------------------------------------------------------------
development:&development
adapter:mysql2
encoding:utf8
database:fat_free_crm_development
pool:5
username:root
# password:
socket:/var/run/mysqld/mysqld.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *development
database: fat_free_crm_test
production:
adapter: mysql
encoding: utf8
database: fat_free_crm_production
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
socket: /tmp/mysql.sock
staging:
<<: *development
database: fat_free_crm_staging
希望听到并寻求一些建议和学习。 如果需要更多信息,请告诉我。
谢谢,
【问题讨论】:
-
可能是
config/database.yml中的错误。请发布该文件。 -
您在调试错误方面做得很好,但您忘记检查错误行附近的数据。如果您在错误行之前将
require "pp"; pp config添加到connection_specification.rb中,您可能已经自己解决了错误。记住这个技巧以备不时之需。 -
请不要发布其他文件作为答案。只需编辑原始问题并将其添加到末尾即可。
-
抱歉,编辑完成。 :)
-
Casper 先生再次抱歉给您带来麻烦。关于这个我应该把
require "pp"; pp confing放在哪里?在config = configurations.dup config.each do |key, value|之前还是在.dup 和.each 之间?对不起,我是新手。 :(
标签: ruby-on-rails ruby installation