问题
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 }
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?
回答1:
Have you registred the mime type in your environment.rb ?
Mime::Type.register "text/plist", :plist
this could help http://blog.willj.net/2010/01/25/generating-a-plist-file-in-rails/
bye
来源:https://stackoverflow.com/questions/4733810/how-to-generate-plists-from-rails-models