Hi,
I want to show the validate - message in the flash[:error] - field but I
can’t find any options.
An example:
class UserPermission < ActiveRecord::Base
validates_presence_of :name,
:message => “Please insert a name”
… |
end V
flash[:error] = "Error - "
Has anybody a solution for this problem?
Eddy
What’s wrong with error_messages_for ?
Thorsten M. wrote:
What’s wrong with error_messages_for ?
Hi Thorsten,
error_messages_for and error_messages_on destroy the look and feel of
the application in this case.
Eddy
Thanks Thorsten for your helpful tip.
@user_permission.errors.full_messages() solve my problem.
Eddy
Then most likely the only thing you can do is
manually going through the errors and add them
to the flash (or directly display them in the view)
@user_permission.errors.each_full do |msg|
…
end
will return them one by one as string
or
@user_permission.errors.full_messages()
would return an array with all messages.
I’m quite sure, there is no direct way to tell the validators to do
anything but add the error to the models error object.