# Check for Errors

**URL:** <https://www.ruby-forum.com/t/check-for-errors/127655>\
**Category:** Rails\
**Created:** [January 31, 2008, 3:36am UTC](https://www.ruby-forum.com/t/check-for-errors/127655 "2008-01-31T03:36:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce73a5/32.png) [@tim](https://www.ruby-forum.com/u/tim)\
**Post date:** [January 31, 2008, 3:36am UTC](https://www.ruby-forum.com/t/check-for-errors/127655/1 "2008-01-31T03:36:14Z")

</div>

in the application.rhtml I am trying to check and see if any of the  
models associated with this controller have errors (i.e. -  
model.errors.count \> 0). Does anyone know how to do that using  
reflection or something since I will not know what models are present  
in this controller or action of the controller since it is in the  
shared application.rhtml file??

Thanks!

---

<div class="post-metadata">

**Author:** ![tim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce73a5/32.png) [@tim](https://www.ruby-forum.com/u/tim)\
**Post date:** [January 31, 2008, 6:02am UTC](https://www.ruby-forum.com/t/check-for-errors/127655/2 "2008-01-31T06:02:15Z")

</div>

In your controller you could define a flash message:

def create  
@thing = Thing.new(params[:thing])  
if @thing.save  
flash[:notice] = “Thing was saved correctly.”  
else  
flash[:notice] = “Thing could not be saved: #{@thing.errors.to\_s}”  
end  
end

On Jan 31, 2008 1:05 PM, Tim [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.
