I think differently: Why can’t you use JavaScript to check for a blank
field?
No way! JavaScript validations should never be relied on – it’s too
easy for the client to turn them off and bypass them, or to submit a
crafted GET or POST request that bypasses the HTML form entirely.
Validation must be done on the server side.
class Post < ActiveRecord::Base
validates :name , :presence => { :message=>“Post name can’t be
blank.”
}
end
Maksim.
Am 20.09.2010 14:49, schrieb Mike D.:
Can anyone tell me How to give the custom message in rails 3 model
validations?
Thanks,
Mike
–
Maksim G.
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66 [email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
USt-ID DE 193477690
Geschäftsführer Sven Haubold
it’s the default error_message_on behavior. You can try to override it.
Another solution could be to write your message without the attribute:
just “can’t be blank.”, so you get “Name can’t be blank”.
Hope it helps you. Regards,
Maksim.
Am 23.09.2010 12:09, schrieb Mike D.:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.