Rails + RABL自定义动态键

时间:2012-03-05 13:51:19

标签: ruby-on-rails json rabl

是否可以使用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

选项已序列化

非常感谢

0 个答案:

没有答案