OSDN Git Service

t#30199:update i18n error caption
[pettanr/pettanr.git] / app / helpers / application_helper.rb
1 module ApplicationHelper
2   def full_url filename
3     request.protocol + request.host_with_port + filename
4   end
5   
6   def t_m(label)
7     l = label.split('.')
8     if l.size > 2
9       label
10     else
11       if l.size == 1
12         label.constantize.model_name.human
13       else
14         l.first.constantize.human_attribute_name(l.last)
15       end
16     end
17   end
18   
19   def t_select_items(items)
20     items.map {|i| [t(i[0]), i[1]] }
21   end
22   
23   def t_selected_item(name, index)
24     t(MagicNumber[name][index][0])
25   end
26   
27 end