get "affiliate-products" => "application#affiliate_products"
def affiliate_products
@products = AffiliateProducts.fetch
end
class AffiliateProducts < ActiveRecord::Base
def self.fetch
response = RestClient::Request.execute(
:method => :get,
:url => "http://api.shopstyle.com/api/v2/products?pid=uid7849-6112293-28&fts=women&offset=0&limit=10"
)
@products = JSON.parse(response)["products"].map do |product|
product = OpenStruct.new(product)
end
end
end