如何从Rails模型生成桩头? [英] How to generate plists from rails models?

查看:75
本文介绍了如何从Rails模型生成桩头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对红宝石(在轨道上)很陌生,我无法弄清楚这一点;
将对象序列化到rails中的plist的最佳方法是什么?
我正在使用rubyforge的plist库.
而且我有nested_attributes:

I'm rather new at ruby (on rails) and I can't figure this one out;
What is the best way to serialize objects to plist in rails?
I'm using the plist library from rubyforge.
And I have nested_attributes:

class Deck  
deck has_many :cards  
accepts_nested_attributes_for :cards  

class Card  
belongs_to :deck

我已经在套牌控制器中尝试执行此操作:

I've tried in the deck controller to do this:

format.plist { render :plist => @deck.to_plist }

但是我没得到卡片...
类似于xml,我可以这样做:

But I don't get the cards...
Similar in xml, I can do this:

format.xml  { render :xml => @deck.to_xml(:include => :cards) }

并获得所需的输出.
谁能帮助我或指出正确的方向?

And get the desired output.
Can anyone help or point me in the right direction?

推荐答案

您是否已在环境中注册了mime类型.rb?

Have you registred the mime type in your environment.rb ?

Mime::Type.register "text/plist", :plist

这可以帮助 http://blog.willj.net/2010/01/25/generating-a-plist-file-in-rails/

再见

这篇关于如何从Rails模型生成桩头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆