Skip to content

Instantly share code, notes, and snippets.

@rystraum
Created February 21, 2017 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rystraum/ec3d658eeff7b31c749835bee687fc60 to your computer and use it in GitHub Desktop.
Save rystraum/ec3d658eeff7b31c749835bee687fc60 to your computer and use it in GitHub Desktop.
# 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