У меня есть форма для добавления формы json url. Если пользователь добавляет json url и отправляет форму, я хочу сохранить все данные json в БД. [форма] 1
Извлечение данных json из URL с использованием httparty
gem работает отлично, теперь для сохранения данных json в db json_url
json data
{
"restaurant_name": "Restaurant 3",
"address": "xyz address",
"country": "United States",
"currency": "USD",
"client_key": "12345",
"client_name": "Client 3",
"client_email": "test3@mail.com",
"client_phone": "9876",
"product_tier": "tier1",
"brand_logo_large": {
"ID": 37,
"id": 37,
"title": "bait-al-bahar-logo-design",
"filename": "bait-al-bahar-logo-design.png",
"filesize": 105071,
"url": "http://codekyt.in/froodle-wp/wp-content/uploads/2019/01/bait-al-bahar-logo-design.png",
"link": "http://codekyt.in/froodle-wp/projects/res-1-client-1/bait-al-bahar-logo-design/",
"alt": "",
"author": "1",
"description": "",
"caption": "",
"name": "bait-al-bahar-logo-design",
"status": "inherit",
"uploaded_to": 35,
"date": "2019-01-04 11:11:48",
"modified": "2019-01-04 11:13:01",
"menu_order": 0,
"mime_type": "image/png",
"type": "image",
"subtype": "png",
"icon": "http://codekyt.in/froodle-wp/wp-includes/images/media/default.png",
"width": 600,
"height": 500,
"sizes": {
"thumbnail": "http://codekyt.in/froodle-wp/wp-content/uploads/2019/01/bait-al-bahar-logo-design-150x150.png",
"thumbnail-width": 150,
"thumbnail-height": 150,
"medium": "http://codekyt.in/froodle-wp/wp-content/uploads/2019/01/bait-al-bahar-logo-design-300x250.png",
"medium-width": 300,
"medium-height": 250,
"medium_large": "http://codekyt.in/froodle-wp/wp-content/uploads/2019/01/bait-al-bahar-logo-design.png",
"medium_large-width": 600,
"medium_large-height": 500,
"large": "http://codekyt.in/froodle-wp/wp-content/uploads/2019/01/bait-al-bahar-logo-design.png",
"large-width": 600,
"large-height": 500
}
}
}
Я создал форму для пользователя и добавил json url,
<%= form_tag("/settings/json_url", method: "post") do %>
<%= label_tag :json_url %>
<%= text_field_tag :json_url %>
<%= submit_tag 'submit' %>
<% end %>
В дБ,
t.string :key
t.string :value
t.string :json_url
В контроллере,
def json_url
# I am getting confused here
end