ruby - Custom Validations Rails Model -


i have contact form , show individual messages depending on has failed.i use flash messages. have read far can create custom method (or think overrides 1 in place?)

so example, want validate presence of name field

class message  attr_accessor :name validates :name, :presence => true  def validate  if self.name < 0   errors.add(:name, "name cannot blank")  end end end 

within controller use generic message

flash.now.alert = "please ensure fields filled in" 

is there way call particular message failed validation?

thanks

there plugin available, u can follow below url

https://github.com/jeremydurham/custom-err-msg 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -