나는 this railscast을 따라 가고 자습서를 끝 냈습니다. 모든 것이 잘 작동했습니다. '내가 봤HStore 및 레일이있는 동적 양식 4
PG::Error: ERROR: Syntax error near '!' at position 4 : INSERT INTO "products" ("product_type_id", "created_at", "properties", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"
및 similar SO question을 발견,하지만 난 가정 아무튼 레일 4를 사용하고 있습니다 : 그럼 난 직렬화 된 해시 대신 hstore를 사용하기로 결정하고, hstore을 설정 한 후 오류로 실행 그 보석을 더 이상 사용할 필요가 없습니다. 여기
내 코드입니다 : 내 form.html.haml의 관련 부분이= f.fields_for :properties, OpenStruct.new(@product.properties) do |builder|
- @product.product_type.products.each do |product|
= render "products/fields/#{product.field_type}", field: field, f: builder
내 제품 모델처럼 보이는
은 다음과 같습니다
이class Product < ActiveRecord::Base
belongs_to :product_type
serialize :properties
end
내가 게시 할 수 있습니다 더 코드가 도움이된다면. 감사!
Rails4에서 hstore와 함께'serialize'를 사용해야합니까? 나는 그것을 사용하지 않았지만 hstore가 Rails4 PostgreSQL 드라이버에 의해 기본적으로 이해되었다고 생각하여'serialize' kludgery가 더 이상 필요하지 않게되었습니다. 오류 메시지의'!'는 YAML에 나타나며, 그것은'serialize'가 기본적으로 사용하는 것입니다. –
@muistooshort, 그건 실제로 문제를 해결했습니다. 그걸 내가 대답 할 수 있도록 해줄 수 있겠 니? –