0

I have an_errors.html.erb that takes an object and has

<%= object.class.name %>.

It is called by this in a _form.html.erb:

<%= render 'shared/errors', object: @product %>

What should I write in my xx.yml file to find the translation?

I have

models:
  product: Produkt

which doesn't do the job.

Any clues?

Cheers Carl

abegbg
  • 191
  • 2
  • 11

1 Answers1

0

I'm not quite clear on what you are going after, however, the following might work.

In your YAML file:

models: 
  product: 'Product' 

In your ERB view:

# The following assumes "object" in your original post relates to the string (Product) in the YAML file 
<%= object.constantize %> # this outputs the details of your class 
<%= object.constantize.to_s %> # would be a string representation of your class (i.e., 'Product') 

API docs for Constantize

Again, was not 100% sure what you were looking to accomplish but wanted to offer the suggestion in the event it helps!

craig.kaminsky
  • 5,588
  • 28
  • 31
  • I made some clarifications. 'object' is an object of the Product class. <%= object.class.name.constantize %> gives me 'Product', but not my translated version. – abegbg Feb 04 '16 at 20:54