About Error handler

Hi

I am new to ruby on rails
I need to know one thing
Is there any way to externalize all the error messages in one file and
access


Karthik.k
Mobile - +91-9894991640

On Jul 21, 11:44 am, karthik k [email protected] wrote:

Hi

I am new to ruby on rails
I need to know one thing
Is there any way to externalize all the error messages in one file and
access


Karthik.k
Mobile - +91-9894991640

Do you mean the error messages from a model instance? You can just use
ruby’s standard file io methods to read and write a yaml file:

File.open(‘errors.yml’, ‘w’) do |out|
out.write(my_obj.errors.full_messages.to_yaml)
end

to read it back in:
errors = YAML.load_file(‘errors.yml’)

Evan C wrote:

On Jul 21, 11:44�am, karthik k [email protected] wrote:

Hi

I am new to ruby on rails
I need to know one thing
Is there any way to externalize all the error messages in one file and
access


Karthik.k
Mobile - +91-9894991640

Do you mean the error messages from a model instance? You can just use
ruby’s standard file io methods to read and write a yaml file:

File.open(‘errors.yml’, ‘w’) do |out|
out.write(my_obj.errors.full_messages.to_yaml)
end

to read it back in:
errors = YAML.load_file(‘errors.yml’)

hi Evan

Thank you for spending your precious time
As i am very new to ruby on rails can i find any sample application on
the above
because i have some 50 models and all the error should be in one file
e.g errors.yml

Even i dont know where to put this errors.yml file

Please guide me
karthik.k