Vote count:
0
I have a model Car in my application. I've added color field. My migration looks like this:
class AddColorToCars < ActiveRecord::Migration
def change
add_column :cars, :color, :string
Car.all.each do |car|
car.color = "silver"
car.save
end
end
end
in my form I've add:
= f.input :color
and in Car model I've added validation:
validates :color, presence: true
When I try edit existing Car and change his color to be nil I have the following error:
ERROR: current transaction is aborted, commands ignored until end of transaction block
When I disable my validation everything works fine. What's wrong?
asked 2 mins ago
Aucun commentaire:
Enregistrer un commentaire