5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 01:21:42 +00:00
panel/app/helpers/application_helper.rb

22 lines
433 B
Ruby
Raw Normal View History

2018-01-02 17:19:25 +00:00
module ApplicationHelper
# Devuelve el atributo name de un campo posiblemente anidado
def field_name_for_post(names)
return ['post', names] if names.is_a? String
names = names.dup
root = 'post'
name = names.pop
names.each do |n|
root = "#{root}[#{n}]"
end
[root, name]
end
def field_name_for_post_as_string(names)
f = field_name_for_post(names)
"#{f.first}[#{f.last}]"
end
2018-01-02 17:19:25 +00:00
end