class SpeechBalloon < ActiveRecord::Base
- has_many :balloons, :dependent => :destroy
- has_many :speeches, :dependent => :destroy
+ has_one :balloon, :dependent => :destroy
+ has_one :speech, :dependent => :destroy
belongs_to :speech_balloon_template
belongs_to :panel
- accepts_nested_attributes_for :balloons
- accepts_nested_attributes_for :speeches
+ accepts_nested_attributes_for :balloon
+ accepts_nested_attributes_for :speech
validates :panel_id, :numericality => {:allow_blank => true}
validates :speech_balloon_template_id, :presence => true, :numericality => true, :existence => {:both => false}
end
def self.list_opt
- {:include => {:panel => {:author => {}}, :balloons => {}, :speeches => {}, :speech_balloon_template => {} }}
+ {:include => {:panel => {:author => {}}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
end
def self.list_json_opt
- {:include => {:panel => {:include => {:author => {} }}, :balloons => {}, :speeches => {}, :speech_balloon_template => {} }}
+ {:include => {:panel => {:include => {:author => {} }}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
end
def self.show cid, au
end
def self.show_opt
- {:include => {:panel => {:author => {}}, :balloons => {}, :speeches => {}, :speech_balloon_template => {} }}
+ {:include => {:panel => {:author => {}}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
end
def self.show_json_opt
- {:include => {:panel => {:include => {:author => {} }}, :balloons => {}, :speeches => {}, :speech_balloon_template => {} }}
+ {:include => {:panel => {:include => {:author => {} }}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
end
def scenario
- balloons.first.scenario.to_s +
- speeches.map {|s| s.scenario }.join
+ ERB::Util.html_escape(self.caption.to_s) + self.balloon.scenario.to_s +
+ self.speech.scenario.to_s
end
def plain_scenario
- balloons.first.plain_scenario.to_s +
- speeches.map {|s| s.plain_scenario }.join
+ self.caption.to_s + self.balloon.plain_scenario.to_s +
+ self.speech.plain_scenario.to_s
end
end