Different view based on different model


#1

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 ‘removed_email_address@domain.invalid’%>

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?


#2

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