使用Redis和Rails 4.2.0的问题,无法运行rails控制台

时间:2015-02-18 20:55:17

标签: ruby-on-rails ruby redis

我在简单的标准rails应用程序上运行redis时遇到问题。我在我的Gemfile中添加了redis:

1  source 'https://rubygems.org'                                                                                                                                         
2                                                                                                                                                                       
3  gem 'coffee-rails', '~> 4.1.0'                                                                                                                                        
4  gem 'jbuilder', '~> 2.0'                                                                                                                                              
5  gem 'jquery-rails'                                                                                                                                                    
6  gem 'pg'                                                                                                                                                              
7  gem 'rails', '4.2.0'                                                                                                                                                  
8  gem 'redis'                                                                                                                                                           
9  gem 'sass-rails', '~> 5.0'                                                                                                                                            
10 gem 'sdoc', '~> 0.4.0', group: :doc                                                                                                                                   
11 gem 'uglifier', '>= 1.3.0'

然后我安装了bundle,并添加了config / initializers / redis.rb:

$redis = Redis.new(:host => 'localhost', :port => 6379)

当我去运行rails console时,我想出了这个错误。

/home/adam/dev/Sandbox/Redis/config/application.rb:17:in `<top (required)>': Redis is not a module (TypeError)
    from /home/adam/.gem/ruby/2.1.5/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:141:in `require'
    from /home/adam/.gem/ruby/2.1.5/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:141:in `require_application_and_environment!'
    from /home/adam/.gem/ruby/2.1.5/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:67:in `console'
    from /home/adam/.gem/ruby/2.1.5/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /home/adam/.gem/ruby/2.1.5/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

我不确定如何解决这个问题,并会感激一些帮助。

0 个答案:

没有答案