/ ActiveRecord के साथ Hashes की सरणी - रूबी-ऑन-रेल, पोस्टग्रैक्कल, एक्टिवरकार्ड

ActiveRecord के साथ हैश के ऐरे - रूबी-ऑन-रेल, postgresql, activerecord

ActiveRecord (Rails 4.0) PostgreSQL Hstore और Array डेटाटेस का समर्थन करता है, इसलिए Hashes का Array सैद्धांतिक रूप से संभव है, लेकिन मेरा कार्यान्वयन फेंकता है:

PG::InvalidTextRepresentation: ERROR:  malformed array literal:

त्रुटि स्पष्ट है (दोहरे उद्धरण संघर्ष):

"{"null"=>"false","name"=>"schema_id","type"=>"integer","null"=>"false","name"=>"title","type"=>"text"}"

: INSERT INTO "entities" ("attribute_hash", "schema_id", "title") VALUES ($1, $2, $3) RETURNING "id"

समाधान मेरे लिए स्पष्ट नहीं है, मैं इसे कैसे लागू कर सकता हूं?

मेरा स्कीमा:

create_table :schemas do |t|
t.text    :title
t.timestamps
end

create_table :entities do |t|
t.integer :schema_id,       null: false
t.text    :title,           null: false
t.hstore  :attribute_hash, array: true
end

मेरा बीज:

@schema_id = Schema.create!(title: "accreu")
Entity.create!(
schema_id: @schema_id.id, title: "entities",
attribute_hash: [
{null: "false", name: :schema_id, type: :integer},
{null: "false", name: :title, type: :text}
]
)

उत्तर:

जवाब के लिए 3 № 1

यह रेल्स में एक पुष्टिकृत बग है जो कमिट में तय किया गया था 7c32db1, जो 4.1.0.rc1 और बाद के संस्करणों में मौजूद है।