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
选项被序列化
非常感谢