Different view based on different model

I have a view that looks like this “Add a New #{@element.class}”
where my class can be “definition”, “phrase”, etc.

I want to do something like

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

so when @element is a “phrase” my view would show “Add New Phrase”, When
my @element is a “definition” my view needs to be “Add New Definition”

Is this possible?

This forum must really not get much traffic. Anywhoo, I solved my own
problem

<% type_of_element = @element.class.to_s.downcase %>
<% add_element_to_translate =
[“model”, “add”, type_of_element
].compact.join(’.’)%>
<%= t add_element_to_translate %>

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


Richard
http://www.slangslang.com

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