#コミック
class Comic < ActiveRecord::Base
- has_many :stories
+ has_many :stories, :order => 't'
belongs_to :author
validates :title, :presence => true, :length => {:maximum => 100}
res = false
Comic.transaction do
self.stories.each do |story|
- raise ActiveRecord::Rollback unless story.destroy
+ raise ActiveRecord::Rollback unless story.destroy_and_shorten
end
raise ActiveRecord::Rollback unless self.destroy
res = true