[Rails] Re: Add line break to custom error message

2010-10-12 Thread Jim Burgess
Just a follow up in case this helps anyone else: > You could also probably put a literal "" in the error message, then > use unescape_html. As it turns out, simple_format was wrapping everything in < p > tags, which was causing invalid html to be generated in the error view of my form. So, I tri

[Rails] Re: Add line break to custom error message

2010-09-27 Thread pepe
Thanks Jim On Sep 27, 3:29 pm, Jim Burgess wrote: > pepe wrote: > > If you do, please post the solution. I would like to know. > > Hi Pepe, > > so, after a week of trying I finally found the solution and am posting > it here in case it helps anyone else. > > Error message in model: > > errors.add

[Rails] Re: Add line break to custom error message

2010-09-27 Thread Marnen Laibow-Koser
Jim Burgess wrote: > pepe wrote: >> If you do, please post the solution. I would like to know. > > Hi Pepe, > > so, after a week of trying I finally found the solution and am posting > it here in case it helps anyone else. > > Error message in model: > > errors.add(field, "This field is too l

[Rails] Re: Add line break to custom error message

2010-09-27 Thread Jim Burgess
pepe wrote: > If you do, please post the solution. I would like to know. Hi Pepe, so, after a week of trying I finally found the solution and am posting it here in case it helps anyone else. Error message in model: errors.add(field, "This field is too long.\nYou are using #{self[field].lengt

[Rails] Re: Add line break to custom error message

2010-09-21 Thread pepe
I have not been able to find a way of breaking the line, except by breaking the message in 2 separate ones as I explained before. If you do, please post the solution. I would like to know. Sorry I couldn't be of much help. On Sep 21, 5:52 pm, Jim Burgess wrote: > > First line<%= sanitize('') -%>S

[Rails] Re: Add line break to custom error message

2010-09-21 Thread pepe
> I tried: > > errors.add(:thesis, "This field is too long. <%= sanitize('') -%> > You are using #{field.length} characters out of a permitted > #{permitted}.") > > This produced: > "This field is way too long. <%= sanitize('') -%> You are using > 12600 characters out of a permitted 1000." > > In t

[Rails] Re: Add line break to custom error message

2010-09-21 Thread Jim Burgess
> First line<%= sanitize('') -%>Second line I tried: errors.add(:thesis, "This field is too long. <%= sanitize('') -%> You are using #{field.length} characters out of a permitted #{permitted}.") This produced: "This field is way too long. <%= sanitize('') -%> You are using 12600 characters ou

[Rails] Re: Add line break to custom error message

2010-09-21 Thread pepe
Adding this to a regular page broke the string in 2 lines on the page: First line<%= sanitize('') -%>Second line It's not the same thing but it might work? > The source reads: > > This field is too long. & l t ; br /& g t ;You are using 12600 > characters out of a permitted 1000. > > (I have put

[Rails] Re: Add line break to custom error message

2010-09-21 Thread Jim Burgess
pepe wrote: > Have you checked the source to see what was the HTML output? Thanks for the answer. The source reads: This field is too long. & l t ; br /& g t ;You are using 12600 characters out of a permitted 1000. (I have put spaces between the characters so that they don't get parsed when I

[Rails] Re: Add line break to custom error message

2010-09-21 Thread pepe
Never tried it, but I am thinking your first option should work if you sanitize the whole ''. As you posted it, it might be getting processed and made useless by Rails. Have you checked the source to see what was the HTML output? On Sep 21, 2:57 am, Jim Burgess wrote: > Is it possible to add a li