3

RABL でキー名を動的に設定することは可能ですか? 次の形式で出力しようとしています...

snippet_1: {name: 'map', options: {'options[postcode]': "SW64TY"}}, snippet_2: {name: 'map', options: {'options[postcode]': "GU78YU"}}

そして、私はrablビューで次のものを持っています:

collection @snippets => 'snippets'
attribute :snippet_type => :name
attribute :options => :options
attribute :snippet_id => :id

私のテーブルは次のようになります:

  create_table "snippet_instances", :force => true do |t|
    t.string   "snippet_type"
    t.text     "options"
    t.integer  "page_id"
    t.string   "snippet_id"
    t.datetime "created_at",   :null => false
    t.datetime "updated_at",   :null => false
  end

オプションはシリアル化されています

どうもありがとう

4

0 に答える 0