Passing a dynamic class to translate

I have a single form that can be used for multiple models, in my view i
origionally had “Add a New #{@element.class}” how can i write a dynamic
i18n translate call?

I want to do something like

<%= t ‘[email protected]’%>

What is the best way to accomplish this functionality?

figured it out…

<% type_of_element = @element.class.to_s.downcase %>
<% add_element_to_translate =
[“model”, “add”, type_of_element
<%= t add_element_to_translate %>

hopes this helps someone else, if you figure out a better way let me


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs