Answer the question
In order to leave comments, you need to log in
Extracting information from services, how does it work?
Hello. I want to make it so that a person enters into the field (in my application) the id of a book with goodreads and after saving, create a book in my database with a title and information, such as how many pages. Goodreads has a gem https://github.com/sosedoff/goodreads
I would like to know which way to dig in order to implement this? It after all by means of helpers is implemented?
Answer the question
In order to leave comments, you need to log in
No, helpers are needed only to simplify layout in views.
We connect the gem, create a minimal service:
#app/services/goodreads_service.rb
class GoodreadsService
API_KEY = 'api-ключ' (или брать из ENV или использовать rails_config)
API_SECRET = 'секрет'
def initialize
Goodreads.new(api_key: API_KEY, api_secret: API_SECRET)
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question