inside a transaction. ▸ The returned value matters. ▸ `before_destroy { return false }` ▸ Rails uses and sets some default callbacks. ▸ `has_many :assets, dependent: :destroy` CALLBACKS
"IO error" 4 end 5 6 class User < ActiveRecord::Base 7 after_commit :upload_avatar 8 def upload_avatar 9 S3.upload(file) 10 end 11 end 12 13 class BugTest < ActiveSupport::TestCase 14 def test_upload_the_avatar_if_io_error 15 assert_raises { User.create } 16 end 17 end
"IO error" 4 end 5 6 class User < ActiveRecord::Base 7 after_commit :upload_avatar 8 def upload_avatar 9 S3.upload(file) 10 end 11 end 12 13 class BugTest < ActiveSupport::TestCase 14 def test_upload_the_avatar_if_io_error 15 assert_raises { User.create } 16 end 17 end
def authenticate(password); end 3 def upload_avatar(file); end 4 def update_code(); end 5 end 6 7 class Organization < User 8 end 9 10 User.create(login: 'arthurnn') 11 Organization.create(login: 'rails')
module Avatarable 5 def upload_avatar(file); end 6 end 7 8 class User < ActiveRecord::Base 9 include Authenticable 10 include Avatarable 11 end 12 13 class Organization < ActiveRecord::Base 14 include Authenticable 15 include Avatarable 16 end 17 18 User.create(login: 'arthurnn') 19 Organization.create(login: 'rails') STI: SOLUTION