Wrong validation

10 views
Skip to first unread message

Alexandre Bini

unread,
Aug 8, 2009, 5:47:41 PM8/8/09
to Dr Nic's Magic Models
When i try to save 2 employes with a nil register, i´ve the
ActiveRecord::RecordInvalid: Validation failed

I have the following migrate
class CreateEmployees < ActiveRecord::Migration
def self.up
create_table :employees do |t|

t.string :register, :null=>true, :limit=>12, :default=>nil
end
add_index :employees, :register, :unique=>true
end

def self.down
drop_table :employees
end
end


if i remove from the model the generate_validations and add it
validates_uniqueness_of :rg, :allow_nil=>true, :allow_blank=>true
validates_uniqueness_of :cpf, :allow_nil=>true, :allow_blank=>true
that work...

What i can do?

Alexandre Bini

unread,
Aug 10, 2009, 10:17:00 AM8/10/09
to Dr Nic's Magic Models
Reply all
Reply to author
Forward
0 new messages