Reputation: 245
I need to skip the validation on create method.I am using Rails 4 and ruby 2
i have tried like this
@model.save(:validate => false)
it not working
Upvotes: 14
Views: 27534
Reputation: 20145
Assuming you are talking about ActiveRecord
; In Rails 3 and 4 the way to skip validations and potentially persist invalid objects is as you describe:
@model.save(:validate => false)
In Rails 2 you'd need to do
@model.save(false)
Upvotes: 13
Reputation: 1776
validates :some_attr, :presence => true, :unless => :create
skips the validation JUST for create.
Upvotes: 1
Reputation: 5111
You can do this in model by
validates :some_attr, :presence => true, :on => :update
Upvotes: 4