Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off validation in seeds.rb

How do turn off validation in Rails 3.2.3 in seeds.rb? I did this

u1 = User.create email: '[email protected]', password: '123', validate: false

but it said Can't mass-assign protected attributes: validate. I know what it means. So how do I get rid of that error?

like image 973
Alan Coromano Avatar asked Apr 06 '13 09:04

Alan Coromano


1 Answers

You can do

u1 = User.new(email: '[email protected]', password: '123').save(validate: false)
like image 133
iltempo Avatar answered Nov 14 '22 04:11

iltempo