Rails Error Message Without Field Name
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and rails custom validation error message policies of this site About Us Learn more about Stack Overflow the
Rails Change Field Name Error Message
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags rails validation change attribute name Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only
Rails Human_attribute_name
takes a minute: Sign up removing field name from validation error message [duplicate] up vote 7 down vote favorite 3 This question already has an answer here: Fully custom validation error message with Rails 10 answers in rails 3 i don't want to show field names in error messages. Anyone know how to do that ? validates_presence_of :title, :message => "no validates_presence_of message title" it shows Title no title i want no title ruby-on-rails ruby-on-rails-3 share|improve this question asked Mar 21 '11 at 8:42 hakaooa 45113 marked as duplicate by Martijn Pieters♦ Sep 23 '15 at 17:05 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. That's not duplicate. –hlcs Sep 2 at 8:31 add a comment| 6 Answers 6 active oldest votes up vote 17 down vote In your form view change your current code <%@object.errors.full_messages.each do |msg| %>
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow
I18n Ruby
the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Using Rails validation helpers :message but want it without listing the column name in message up vote http://stackoverflow.com/questions/5375407/removing-field-name-from-validation-error-message 19 down vote favorite 6 Using Rails validation helpers- validates_xxx_of :the_column, :message => "my message" will generate a validation message : *the_column my message* Is there a way to turn-off the inclusion of the column name? (substitute xxx with any validation helper method) ruby-on-rails validation share|improve this question asked Mar 27 '09 at 15:40 daustin777 2,34551725 add a comment| 13 Answers 13 active oldest votes up vote 16 down vote I know http://stackoverflow.com/questions/690267/using-rails-validation-helpers-message-but-want-it-without-listing-the-column-n this question is old. But just for reference in case someone else stumbles over it as I just did. At least in Rails 3.0.x (not sure about earlier versions) you can use the leading ^ as indicated by RadBrad without the need for any gems/plugins. share|improve this answer edited Jul 27 '12 at 6:24 answered Nov 24 '10 at 15:22 Hartwig 6131820 The question may be old but your answer was the one I was looking for. +1 –Brian Deterling Dec 4 '10 at 19:28 1 I'm using Rails 3.1 and this does not work. However, I can do: <% object.errors.full_messages.each do |msg| %> <% msg = msg.split("^").last %> ... <% end %> –tybro0103 Dec 31 '11 at 2:02 This does work for me in Rails 3.2.2 –Mitch May 22 '12 at 17:59 3 This does not work for me in Rails 3.2.6 –KenB Jul 26 '12 at 16:54 This didn't work for me (in rails 3.2.11), and it annoyed me a ton. I set it up to work using a helper. In case this is helpful to anyone: resource.errors.full_messages.map{ |m| m.split("^")[1] || m.split("^")[0] } –vansan Jul 10 '13 at 23:02 | show 1 more comment Did you find this question interesting? Try our newslette
In Validation messages without field names? polarapfel (Guest) on 2008-09-02 16:04 Hi everybody, I am getting involved deeper and deeper with Rails development and basically https://www.ruby-forum.com/topic/164533 I love it. However, as Rails was born in the English language world, I find it rather demanding to develop with other end user languages in mind. One of the issues I'm having is with validation error messages. I know how to create custom error messages for validation errors in the models. However, these messages get appended behind the validated error message field name which isn't necessarily human readable or in the application end user language. How do I get rid of model field names in the validation error messages? Just to be very clear this is an example: Say there is a field 'name' in the table 'users' and I validate 'name' in 'User' I get validation error messages like these: 'Name rails error message can't be empty.' I can only replace the 'can't be empty.' part. How Do I get rid if 'Name' in the error message? Thanks, Tobias W. Report post Edit Move Delete topic Reply with quote Re: Validation messages without field names? Erik Dahlstrand (Guest) on 2008-09-02 16:24 There is built in support for this in soon to be released 2.2 (Rails edge). You can read about it here http://iain.nl/2008/09/translating-activerecord/ /Erik Report post Edit Delete Reply with quote Forum List Topic List New Topic Search Register User List Log In Enable email notification | Enable multi-page view Please log in before posting. Registration is free and takes only a minute. Existing account User name or e-mail address Password Always use SSL (experimental!) NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required! Log in with Google account | Log in with Yahoo account | Log in with Facebook account No account? Register here. Forum List Topic List New Topic Search Register User List Log In Powered by RForum and Captchator. Contact information - E-Mail: webmaster (at) ruby-forum (dot) com.