Ruby on rails Rails4:如何将rails应用程序连接到API数据库?

Ruby on rails Rails4:如何将rails应用程序连接到API数据库?,ruby-on-rails,json,api,external,Ruby On Rails,Json,Api,External,不再是问题了 我得到的是: GET api/Products?apiKey={apiKey} 它以以下格式(application/json、text/json)返回机场所有商店中可用的所有产品: 因此,为了能够从这个API访问数据,我需要在请求URI中定义它(我想),我如何才能做到这一点,以及如何将这个外部数据用于我的应用程序 请在回答中明确我应该在哪里定义参数来连接rails应用程序中的API 谢谢 编辑: 什么帮助我(我是初学者): 要从外部API读取数据,通常需要在API周围编写一个

不再是问题了

我得到的是:

GET api/Products?apiKey={apiKey}
它以以下格式(application/json、text/json)返回机场所有商店中可用的所有产品:

因此,为了能够从这个API访问数据,我需要在请求URI中定义它(我想),我如何才能做到这一点,以及如何将这个外部数据用于我的应用程序

请在回答中明确我应该在哪里定义参数来连接rails应用程序中的API

谢谢

编辑: 什么帮助我(我是初学者):


要从外部API读取数据,通常需要在API周围编写一个包装器。例如,使用httparty(,警告这可能会稍微慢一点,但这是一个更容易的开始)。一旦你有了数据,你就会把它放在一个类似散列的对象中,你如何处理它,这取决于你自己

可能重复的
[
  {
    "ProductShop": {
      "AirportName": "sample string 1",
      "ADCShopCode": "sample string 2",
      "libShop": "sample string 3",
      "StorePhoneNumber": "sample string 4",
      "idPoi": 5,
      "PoiName": "sample string 6"
    },
    "productActivity": "sample string 1",
    "productBrand": "sample string 2",
    "ProductFamily": "sample string 3"
  },
... ]