【问题标题】:Consuming a rest API in rails 3.2.13在 rails 3.2.13 中使用 rest API
【发布时间】:2013-04-24 07:44:37
【问题描述】:

我有两个 Rails 应用程序在不同的端口上运行。我正在尝试从一个应用程序使用另一个应用程序的 API。 这是 APP_1 中 Product.rb 模型的代码。

class Product < ActiveResource::Base
  self.site = "https://localhost:3000"
  self.ssl_options = {:cert         => OpenSSL::X509::Certificate.new(File.open(pem_file)),
                      :key          => OpenSSL::PKey::RSA.new(File.open(pem_file)),
                      :ca_path      => "/path/to/OpenSSL/formatted/CA_Certs",
                      :verify_mode  => OpenSSL::SSL::VERIFY_PEER}
end

我为 Product 模型设置了控制器和路由。当我运行 APP_1 我得到 ​​p>

 undefined local variable or method `pem_file' for Product:Class

谁能告诉我如何写一个pem文件,什么是pem文件?

【问题讨论】:

    标签: ruby ruby-on-rails-3 api openssl activeresource


    【解决方案1】:

    查看: https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file

    这应该足以让您开始使用谷歌搜索和寻找您的解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 2013-04-03
      • 1970-01-01
      • 2011-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多