在rails 3.2.13中使用rest API

时间:2013-04-24 07:44:38

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

我有两个在不同端口上运行的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

我为产品型号设置了控制器和路线。当我运行APP_1时,我得到了

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

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

1 个答案:

答案 0 :(得分:1)