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
  1. Install ‘rest-client’ gem
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

--

--

--

Fullstack Software Engineer | Musician | Food Lover | Coffee Addict

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to create an application on Private Blockchain ??

HackerRank: Sum vs XOR

A Different Look At API Tests With Rest Assured, JUnit 5 and Kotlin

Why IT and Software Delivery Service Cycles Are Getting So Much Faster

Appium Tutorial - Step by Step Android Automation

Kotlin Native UI

Compiled vs Interpreted Code Performance

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
Grace Yuiko Nakano

Grace Yuiko Nakano

Fullstack Software Engineer | Musician | Food Lover | Coffee Addict

More from Medium

Aluminium and Humankind’s Passion to explore ‘Space’ — The Final Frontier

Ninpu app : to accompany and support women during and after pregnancy

Best Mouse For Runescape

How to join 001 and 002 files.