我是 Rails 的新手,但大多数文档都是针对用户在视图中输入内容并最终传递到数据库中的。
- 是否有一种将以下存储到 SQL 数据库中的 Rails 方式?我把它放在模型或控制器中吗?
- 有没有一种干净的方法来存储这些数据,或者我必须单独显式地存储这个 Hash 中的每个属性?
- 我已经手动进行了与下面大多数(如果不是全部)散列数据匹配的迁移,但是是否有可以将这些散列转换为关系数据模型的工具?
.
{
"_id" : "36483f88e04d6dcb60684a33000791a6bc522a41",
"address_components" : [
{
"long_name" : "ON",
"short_name" : "ON",
"types" : [
"administrative_area_level_1",
"political"
]
},
{
"long_name" : "CA",
"short_name" : "CA",
"types" : [
"country",
"political"
]
},
{
"long_name" : "M5J 1L4",
"short_name" : "M5J 1L4",
"types" : [
"postal_code"
]
}
],
"formatted_address" : "ON, Canada",
"formatted_phone_number" : "(416) 362-5221",
"geometry" : {
"location" : {
"lat" : 43.640816,
"lng" : -79.381752
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "36483f88e04d6dcb60684a33000791a6bc522a41",
"international_phone_number" : "+1 416-362-5221",
"name" : "Scandinavian Airlines",
"reference" : "CoQBcgAAAMobbidhAbzwIMkxq3GTHzzlEW4hAAwxg5EmGDP7ZOcJRwUK29poFMTDvED5KW9UEQrqtgTwESj_DuCAchy6Qe5pPZH9tB47MmmuQHvyHFlApunmU3MN05_KLekN5hEbrW7Gv2ys2oXmn7FpvD7-0N0QILlFXCiwL5UlYWo2sEg3EhBMBsrkHBu4WCFsMCHRqgadGhTM3BVWR15l9L87zL1uN1ssoW4WCw",
"types" : [
"restaurant",
"food",
"establishment"
],
"url" : "https://plus.google.com/100786723768255083253/about?hl=en-US",
"utc_offset" : -300,
"vicinity" : ""
}