尝试在Vagrant vm上启动rails服务器时出错

时间:2014-06-07 16:53:45

标签: sql ruby-on-rails vagrant

下面是我尝试运行时获得的控制台错误消息" rails s"在一个流浪汉的VM上。它以所有这些错误消息退出,第一行是 /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in`initialize' ;:连接被拒绝 - 连接(2)(Errno :: ECONNREFUSED)

不确定这里发生了什么......

非常感谢


设置\初始化\ tire.rb     subdomain =""

if Rails.env.alpha?
  subdomain = ".alpha."
end

if Rails.env.development?
  Tire.configure { logger 'log/elasticsearch_development.log', :level => 'debug' }
else
  Tire.configure { logger "log/elasticsearch.#{Rails.env.to_s.downcase}.log" }
end

prefix = "org.#{Rails.application.class.parent_name.downcase}#{subdomain}_#{Rails.env.to_s.downcase}"
Tire::Model::Search.index_prefix(prefix)


def get_indices_for_env(prefix)
  aliases = Tire::Configuration.client.get(Tire::Configuration.url + '/_aliases').body
  global_indices = MultiJson.load(aliases).keys

  all_indices = global_indices.select do |index|
    index.start_with? prefix
  end
  all_indices.freeze
end

ALL_INDICES = get_indices_for_env(prefix)

错误消息


  

vagrant @ precise32:/ vagrant $ bundle exec rails s   =&GT;启动WEBrick   =&GT; Rails 3.2.17应用程序从http://x.x.x.x:3000开始开发   =&GT;用-d调用分离   =&GT; Ctrl-C关闭服务器退出/home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in   initialize': Connection refused - connect(2) (Errno::ECONNREFUSED) from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in 开放&#39;           来自/home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in   block in connect' from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in 超时&#39;           来自/home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:877:in   connect' from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:862:in do_start&#39;           来自/home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:851:in   start' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in 发送&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in   execute' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/tire-0.6.2/lib/tire/http/client.rb:11:in 让&#39;           来自/vagrant/config/initializers/tire.rb:20:in get_indices_for_env' from /vagrant/config/initializers/tire.rb:29:in&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:245:in   load' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:245:in 阻止加载&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:236:in   load_dependency' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:245:in 负载&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/engine.rb:593:in   block (2 levels) in <class:Engine>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/engine.rb:592:in 各&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/engine.rb:592:in   block in <class:Engine>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:30:in instance_exec&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:30:in   run_initializers中的run' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:55:in 阻止&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:54:in   each' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:54:in run_initializers&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/application.rb:136:in   initialize!' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in 的method_missing&#39;           来自/vagrant/config/environment.rb:5:in <top (required)>' from /vagrant/config.ru:3:in要求&#39;           来自/vagrant/config.ru:3:in block in <main>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:51:in instance_eval&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:51:in   initialize' from /vagrant/config.ru:in新&#39;           来自/vagrant/config.ru:in <main>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:40:in eval&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:40:in   parse_file' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/server.rb:200:in 应用&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands/server.rb:46:in   app' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/server.rb:304:in wrapped_app&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/server.rb:254:in   start' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands/server.rb:70:in 开始&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands.rb:55:in   block in <top (required)>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands.rb:50:in 挖掘&#39;           来自/home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands.rb:50:in   <top (required)>' from script/rails:6:in需要&#39;           来自script / rails:6:在`&#39;

1 个答案:

答案 0 :(得分:1)

就像上面评论的house9一样,我基本上注释掉了导致我出现问题的整个ruby文件。

然后我在启动Rails服务器时遇到问题,因为它无法找到数据库。所以它抛出了一个ActiveRecord错误:

  

PostsController #homepage中的ActiveRecord :: StatementInvalid   Mysql2 ::错误:'where子句'中的未知列'posts.status':SELECT   帖子。* FROM帖子WHERE posts.status ='PUBLISHED'AND   posts.post_type ='关于'AND(标题类似'关于Ourgoods%')ORDER BY   created_at DESC LIMIT 1 ....

将我拥有的.sql文件连接到Rails应用程序后(按照How do I connect a mysql database file to a local ruby on rails application的说明操作),并运行rake db:migrate,我终于让rails工作了!