Ruby/Rails/DB/PF -v => 1.8.6/2.3.2/mysql/Winxp
user.rb
class User
validates_presence_of :name
end
code 1
def destroy
User.count #=> 0
User.transaction do
User.create({:name=>“kkk”})
User.create({:name=>nil})
end
User.count #=> 1
end
why it is stored one record only even it is in side transaction block
but below code working perfectly
#code 2
def destroy
User.transaction do
begin
User.create!({:name=>“kkk”})
User.create!({:name=>nil})
rescue
end
end
end
i want to know, why the transaction is not happedned in previous code
is it behaviour of Mysql database ?
or
behaviour of Rails?