如何从rails模型生成plist?
我对ruby很感兴趣(在铁轨上),我无法想出这个;
将对象序列化为轨道中的plist的最佳方法是什么?
我正在使用rubyforge的plist库。
我有nested_attributes:
class Deck deck has_many :cards accepts_nested_attributes_for :cards class Card belongs_to :deck
我已经尝试在甲板控制器中执行此操作:
format.plist { render :plist => @deck.to_plist }
但我没有拿到卡片……
类似于xml,我可以这样做:
format.xml { render :xml => @deck.to_xml(:include => :cards) }
并获得所需的输出。
任何人都可以帮助或指出我正确的方向吗?
你有没有在你的环境中注册mime类型.rb?
Mime::Type.register "text/plist", :plist
这可以帮助http://blog.willj.net/2010/01/25/generating-a-plist-file-in-rails/
再见