Created
September 15, 2011 21:27
-
-
Save mattfordham/1220524 to your computer and use it in GitHub Desktop.
Conditional validations breaks client side validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Entry < ActiveRecord::Base | |
validates :first_name, :presence => true, :length => {:maximum => 50}, :if => :condition? | |
def condition? | |
return true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= simple_form_for @entry, :validate => true do |f| | |
= f.input :first_name, :validate => true, :required => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to do:
= f.input :first_name, :input_html => { :validate => true }, :required => true
This is outlined in the SimpleForm wiki page:
https://github.com/bcardarella/client_side_validations/wiki/SimpleForm