Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 具有SSL支持和ruby-debug的瘦身大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有人知道使用Thin同时运行ruby调试器和SSL的方法?

我一直在使用Rails 3.0.10成功使用Thin.

使用Rails server –debugger启动它,我可以调试我的代码.

最近,我还需要为我的应用程序添加SSL支持,并且我希望能够使用自签名证书在本地测试它.

不幸的是,在使用Rails服务器时,我还没有找到一种方法来启动Thin with SSL支持.

我可以使用以下方法成功启动Thin with SSL支持:

thin start --ssl --ssl-verify --ssl-key-file ssllocal/server.key
    --ssl-cert-file ssllocal/server.crt

但是,我还没有找到使用瘦启动激活调试器的方法.

所以我似乎可以选择运行调试器(rails服务器)或SSL(瘦启动),但不能同时运行.

通过修改rails / script文件(see here),似乎可以让Webrick使用Rails服务器运行SSl.我尝试了这种方法,但我没有成功.这是尝试之一:

#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3
# gems installed from the root of your application.

APP_PATH = File.expand_path('../../config/application',__FILE__)
require File.expand_path('../../config/boot',__FILE__)


# THIS IS NEW:
require "rails/commands/server"
require 'rack'
require 'thin'
module Rails
  class Server
    def default_options
      super.merge({
        :Port        => 3000,:environment => (ENV['RAILS_ENV'] || "development").dup,:daemonize   => false,:debugger    => false,:pid         => File.expand_path("tmp/pids/server.pid"),:config      => File.expand_path("config.ru"),:SSLEnable   => true
        :ssl => true,"ssl-verify" => true,"ssl-key-file" => File.expand_path("ssllocal/server.key"),"ssl-cert-file" => File.expand_path("ssllocal/server.crt")       
      })
    end
  end
end


require 'rails/commands'

注意:对于那些可能想知道的人,我在我的根应用程序目录下创建了一个’ssllocal’目录,这就是我存储ssl密钥和证书的地方.

解决方法

您可以尝试在开发环境中自己要求调试器.

你的Gemfile中:

if RUBY_VERSION =~ /^1.9/
  gem "ruby-debug19",:group => :development
else
  gem "ruby-debug",:group => :development
end

在config / environments / development.rb的config块中:

require 'ruby-debug'
Debugger.start

这允许您将调试器语句放在代码中的任何位置.

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – 具有SSL支持和ruby-debug的瘦身全部内容,希望文章能够帮你解决ruby-on-rails – 具有SSL支持和ruby-debug的瘦身所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。