SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    to customize model validation error messages?

    When you use one of the many validation methods that active record has built in, you can print out the error messages in the views with the method "error_messages_for". The output string anyway is a precompiled english string that i want to rewrite with my custom italian string. How can i do that?

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use :message in the validations:

    Code:
    validates_presence_of :title, :message => "should be filled in"
    This will generate a message like "Price should be filled in".

  3. #3
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nd how to customize fully rails validation messages?

  4. #4
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sylow View Post
    ok but i need to customize all the rails string that come out when a validation don't pass, not only to remove the attribute name from the only part of that message that i normally can customize.

  6. #6
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For MijnAntiek.nl

    I use following sample;

    http://textsnippets.com/posts/show/1166

    Does it work for you?

  7. #7
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sylow View Post
    For MijnAntiek.nl

    I use following sample;

    http://textsnippets.com/posts/show/1166

    Does it work for you?
    i will try it anyway from what i see at a first glance it is not what i need 'cause i need to fully customize the rails validation message...i mean also the initial "! error prevent this model...." etc. etc.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •