Utilizing ‘Rest-client’ gem to set unique id’s to objects

rails g resources Recipe title img_url ingredients directions 
gem 'active_model_serializers', '~> 0.10.2'
gem install active_model_serializers -v 0.10.2
rails g serializer recipe
class MemberSerializer < ActiveModel::Serializer  
attributes :id, :title, :image_url, :ingredients, :directions
end
gem 'rest-client', '~> 1.8'
gem install rest-client -v 1.8.0
require 'rest-client'
require 'json'
rm = RestClient.get 'https://CORS-endpoint.com/' rm_array = JSON.parse(rm)rm_array.each do |recipe|
Member.create(
title: recipe["title"],
image_url: recipe["image_url"],
ingredients: recipe["ingredients"],
directions: recipe["directions"]
)
end
rails db:migrate && rails db:seed
rails s

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store