# Errors.add(" ") not shows error message

**URL:** <https://www.ruby-forum.com/t/errors-add-not-shows-error-message/170573>\
**Category:** Rails\
**Created:** [June 19, 2009, 7:41am UTC](https://www.ruby-forum.com/t/errors-add-not-shows-error-message/170573 "2009-06-19T07:41:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 19, 2009, 7:41am UTC](https://www.ruby-forum.com/t/errors-add-not-shows-error-message/170573/1 "2009-06-19T07:41:40Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 19, 2009, 7:28pm UTC](https://www.ruby-forum.com/t/errors-add-not-shows-error-message/170573/2 "2009-06-19T19:28:17Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
