2016-11-10 74 views
3

首先,我真的很抱歉,因为我还是这个新手。未定义的方法`每个'为#<字符串:0x00000003a27a58>

我试着按照这个以下网站的说明安装不含脂肪CRM:

http://www.blogdugeek.fr/crm-installation-fat-free-crm-debian-squeeze/

http://guides.fatfreecrm.com/Setup-Linux-or-Mac-OS.html

当我按照说明,我已经遇到了一些错误,并解决了一些。然而,在执行这个命令:

RAILS_ENV =生产耙分贝:创建分贝:迁移CRM:设置:负载

我被困在此命令行中,在这里有以下的错误,我一直卡在:

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) 

因为我搜索了更多相关的问题,我发现了一些,但它仍然没有用。

另外,这里有一些数据,可能需要:

红宝石版

红宝石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 

希望听到并寻求一些建议和学习。 如果需要更多信息,请告诉我。

感谢,

+0

可能是'config/database.yml'中的错误。请发布该文件。 – Casper

+2

您在调试错误方面做了很多努力,但您忘记检查错误行附近的数据。如果你添加了'require'pp,你可能已经自己解决了错误。 pp config'到错误行之前的'connection_specification.rb'中。记住这个未来的诀窍。 – Casper

+0

请不要发布其他文件作为答案。只需编辑原始问题并将其添加到最后。 – Casper

回答

1

database.yml的问题。 YAML要求在密钥和数据之间有一个分隔符。

所以不喜欢这样的:

production: 
    adapter:mysql 
    encoding:utf8 
    ... 

但是这样的:

production: 
    adapter: mysql 
    encoding: utf8 
    ... 

您需要更正文件中的所有行,因为你有这样的错误随处可见。

+0

对不起,麻烦先生,因为我编辑了database.yml,执行这个命令行时发生错误。** RAILS_ENV =生产rake db:create db:migrate crm:settings:load ** – asd123

+0

发布编辑过的数据库。 yml'文件(从你的问题中删除旧的文件,然后将新版本粘贴到问题中),你可能在某处仍然有错误 – Casper

+0

完成编辑文件:) – asd123

0

再次检查database.yml文件。不要添加任何东西 即文件格式必须正确。 已经不知情地发表评论,导致错误。

相关问题