Şimdiye kadar tamamen çözemediğim için ActiveSupport :: HashWithIndifferentAccess artık kullanamıyorum. ' Artık ActiveSupport :: HashWithIndifferentAccess olarak serileştirilemiyor
class Item < ActiveRecord::Base
serialize :metadata, ActiveSupport::HashWithIndifferentAccess
(Ben denemek ve bunu birlikte zorlamak için seçeneği eklendi ama faydası olmadı Daha önce bu tüm çalışma iyiydi ve bende:
modelinin ilgili kısmı aşağıdaki gibidir. o var.)
Nesne bellekte olduğu sürece, her şey iyi çalışıyor. HashWithIndifferentAccess doğru ve hayat güzel.
mysql> select * from items;
+----+------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| id | link | text | metadata | category_id |
+----+------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| 1 | NULL | Apple Store | ---
id: 42cc7080f964a520e9251fe3
name: Apple Store
contact:
phone: '4153920202'
formattedPhone: (415) 392-0202
location:
address: 1 Stockton St.
crossStreet: at Ellis St.
lat: '37.78573590563453'
lng: '-122.40610713227913'
distance: '1784'
postalCode: '94108'
city: San Francisco
state: CA
country: USA
categories:
'0':
id: 4bf58dd8d48988d122951735
name: Electronics Store
pluralName: Electronics Stores
shortName: Electronics
icon: https://foursquare.com/img/categories/shops/technology.png
parents:
- Shops & Services
primary: 'true'
verified: 'false'
stats:
checkinsCount: '30462'
usersCount: '16105'
tipCount: '128'
url: http://apple.com/sanfrancisco
hereNow:
count: '7'
| 1 |
+----+------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
bir HashWithIndifferentAccess geri zorla edilemez ve herşey böyle havaya uçurmak demektir: Bu
ActiveRecord::SerializationTypeMismatch in Index#index
Showing /development/lists.io/website/app/views/users/_todo.html.haml where line #7 raised:
Attribute was supposed to be a ActiveSupport::HashWithIndifferentAccess, but was a Hash
o veritabanına kaydedilmesini sonra, bunun yerine bir Hash olarak kaydedilir Rails 3.1.3 kullanarak, mysql2 gem sürüm 0.3.10 kullanarak MySQL veri saklamak. Ben de 1.9.2p290 ruby çalışıyorum. Herkesin yararlı olduğunu düşündüğü daha fazla bilgi ekleyebilirim, ancak bunu daha fazla hata ayıklamak için kaydım.