Yes, put your complete message and use errors.on
Sample code:
model
validates_length_of :name, :within=>5..20, :too_short=>"Minimum %d
caractères", :too_long=>"Maximum %d caractères"
view
@blah.errors.on(''name'')
(be careful as you could get an array)
I use the following helper
# Returns an error string for that attribute
def error_for(obj, attr=nil)
return '''' if obj.nil?
return '''' if obj.errors.empty?
if attr.nil?
errors = obj.on_base
errors.is_a?(Array) ? errors.join('', '') : errors
else
errors = obj.errors.on(attr)
errors.is_a?(Array) ? errors.join('', '') : errors
end
end
So in my view:
<%= error_for(@blah, ''name'') %>
Jos
Jérôme L wrote:
>Hi
>
>Is there any way to set up complete messages (not partial) with
>:message for validates_* methods ?
>
>This would be usefull for smarter messages:
>"Topic: please select one." => "Please select a
topic".
>
>and for translations too:
>"Topic: veuillez en choisir un" => "Sélectionnez une
rubrique"
>
>Thanks !
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Rails mailing list
>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>http://lists.rubyonrails.org/mailman/listinfo/rails
>
>