Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i mean in rails, can i build form by reading validation rules.

my user model:

class User < ActiveRecord::Base
    validates :name,
              :email,
              :sex,
              presence: true
    validates :password, presence: true, length: { minimum: 6 }
end

my views/users/_form is original from scaffold generated.

i want my html source code output like this :

for name, email, sex input fields, i want an attributes data-val='true' data-val-required="this field is required"

for password field, an attribute data-val='true' data-val-required='this field is required' data-val-length-min='6'

anyone can help ?

thanks !

share|improve this question
I know Simple Form gem does this somehow, but never dug it. – Michael Szyndel 3 mins ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.