我有像这样的序列化器
class UserSeriazer < ActiveModel::Serializer
attributes :name, :email
end
Run Code Online (Sandbox Code Playgroud)
生成的 json 如下
{
name: 'james'
email: 'j@sample.com'
}
Run Code Online (Sandbox Code Playgroud)
我如何在自定义键下包装上面的json 项目customer
{
customer:
{
name: 'james'
email: 'j@sample.com'
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了诸如属性:名称,:电子邮件,密钥::客户之类的东西,但没有用。提前致谢。
我在Ubuntu 12.10 64bit上使用Ruby 2.1.我无法安装Nokogiri因为它需要libXSLT和libxml.我试图安装这两个,但得到了这个错误:
***@***:~$ sudo apt-get install libxslt-dev libxml2-dev
[sudo] password for :
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
libxml2-dev is already the newest version.
The following NEW packages will be installed:
libxslt1-dev
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 578 kB of archives.
After this operation, 2,422 kB of additional disk space will be used.
Do you want to …
Run Code Online (Sandbox Code Playgroud)