Sha256: d8f86e1d48b290ff5928803944376aeb0614aa713c4a270558b35c32b9b9c96b
Contents?: true
Size: 683 Bytes
Versions: 49
Compression:
Stored size: 683 Bytes
Contents
class Story < Ticket has_one :story_detail, foreign_key: "ticket_id", dependent: :destroy validates :who, :what, presence: true after_save do story_detail.save if story_detail.changed? end [:who, :what, :why].each do |method| define_method(method) do |*args| return nil unless story_detail story_detail.send(method, *args) end define_method("#{method}=") do |*args| build_story_detail unless story_detail story_detail.send("#{method}=", *args) end end def title return super unless who.present? && what.present? title = "#{who} wants to #{what}" title += ", so: #{why}" if why.present? title end end
Version data entries
49 entries across 49 versions & 1 rubygems