Gemfiles和Webrick的依赖问题

时间:2012-05-15 21:50:13

标签: ruby-on-rails ssl webrick

我一直在尝试将webrick配置为在我的应用程序的所有页面上使用SSL。

我添加了

gem 'rack-ssl', :require => 'rack/ssl'

到我的宝石文件和

config.middleware.insert_before ActionDispatch::Static, "Rack::SSL"
config.force_ssl = true

到我的/config/application.rb文件。我将webrick配置为使用我的自签名证书,修改我的/ script / rails文件以便像这样浏览

require 'rubygems'
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'

module Rails
  class Server < ::Rack::Server
    def default_options
      super.merge({
          :Port => 3001,
          :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,
          :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER,
          :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("home/sureweb/rubystuff/server.cert.key").read),
      :SSLCertificate => OpenSSL::X509::Certificate.new(File.open("home/sureweb/rubystuff/server.cert.crt").read),
          :SSLCACertificateFile => 'home/sureweb/rubystuff/server.crt',
          :SSLCertName => [["CN", WEBrick::Utils::getservername]]
     })
    end
  end
end

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

但每次我运行rails时,我都会收到一条消息

You have already activated activesupport 3.2.3, but your Gemfile requires activesupport 3.0.12. Using bundle exec may solve this. (Gem::LoadError)

通常我可以通过删除版本3.2.3来解决这个问题,但我有很多其他依赖它的宝石,所以这不是一个选项。还有另一种方法可以让它发挥作用吗?

0 个答案:

没有答案