Errors.add(" ") not shows error message

Hi ALL…
I want to show error message when entered authority is invalid.
I implemented below in my controller

if params[:user_info][:login].empty?
@user = UserInfo.find_by_login(‘admin’)
@company.authority_id = @user.id
else
authority = UserInfo.find_by_login(params[:user_info][:login])
if authority.nil?
@approval = true
@company.check_authority(@approval)#this method will be called since
authority is invalid
else
@company.authority_id = authority.id
end
end

in my modal i have below function
def check_authority(authority)
puts authority
if authority == true
puts “true”
else
puts “false”
end
puts “check”
errors.add(:authority_id,"*please enter valid authority name") if
authority == true
end

In this above function it prints the value correctly…
But it dosenot show the error message…
What is the reason…
Any guess or suggestion…

This is probably a dumb question, but are you calling
error_messages_for in your view? The code you’ve shown appears to be
correct…

–Matt J.

On Jun 19, 1:41 am, Newb N. [email protected]