Howdy. Ruby Nuby here.
I have a couple of methods in one of my models:
def program_asset if promo? PromoVersion.find(self[:promo_vid]) elsif feature? play_id = self[:play_id] my_play = Playdate.find(play_id) my_fid = my_play[:fid] ProductVersionFormat.find(my_fid) else logger.fatal "Came across a log item that was neither a promo nor a feature: " + self end end
def program_asset_xml program_asset.to_xml(:skip_instruct => true) end
# include the first-level associations. alias_method :ar_to_xml, :to_xml def to_xml(options = {}) default_methods = [:program_asset_xml] options[:methods] = (options[:methods] ? options[:methods] + default_methods : default_methods ) ar_to_xml(options) end
Sort of works okay, except here is a snippet of XML that gets returned to a browser or client:
... <video_guide></video_guide> <program_asset_xml> <promo_version> <anchor_type></anchor_type> <artesia_did type="integer"></artesia_did> ... <video_guide>N</video_guide> </promo_version> </program_asset_xml> ...
The :include-d program asset's XML gets converted into an escaped string, where the angle brackets have been replaced by < and > . What am I doing wrong?
Thanks very much in advance for any help, as well as any other suggestions you may have!