Created
February 21, 2017 15:18
-
-
Save rystraum/ec3d658eeff7b31c749835bee687fc60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# views/items/index.html.erb | |
<dl> | |
<% @items.each do |item| %> | |
<dt><%= item.name %><dt> | |
<dd><%= item.price %></dd> | |
<% end %> | |
</dl> | |
# controllers/items_controller.rb | |
class ItemsController < ApplicationController | |
def index | |
@items = Item.all | |
# @items = API::Item.all | |
end | |
end | |
# models/item.rb -- normal ActiveRecord model | |
class Item < ApplicationRecord | |
# this assumes that you have a database | |
end | |
# models/api/item.rb | |
class API::Item | |
include HTTParty | |
base_uri 'api.shopify.com' | |
def all | |
self.get("/items/", { query: { store_id: "your_store_id_here", api_key: "abc", api_secret: "supersecretthing" } }) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment