Class: Formular::Path
- Inherits:
-
Array
- Object
- Array
- Formular::Path
- Defined in:
- lib/formular/path.rb
Instance Method Summary collapse
-
#to_encoded_id ⇒ Object
need to inject the index in here…
- #to_encoded_name ⇒ Object
Instance Method Details
#to_encoded_id ⇒ Object
need to inject the index in here… else we will end up with the same ids
- User, :name
-
> user_name #regular attribute
- User, roles: 0, :name
-
> user_roles_0_name #nested not rails
DISCUSS: Should we also enable the following for rails accepts_nested_attributes support [User, roles: 0, :name => user_roles_attributes_0_name #nested rails
26 27 28 |
# File 'lib/formular/path.rb', line 26 def to_encoded_id map { |segment| segment.is_a?(Array) ? segment.join('_') : segment }.join('_') end |
#to_encoded_name ⇒ Object
DISCUSS: Should we also enable the following for rails accepts_nested_attributes support
- User, roles: 0, :name => user[0][name
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/formular/path.rb', line 9 def to_encoded_name map.with_index do |segment, i| first_or_last = i == 0 || i == size if first_or_last segment.is_a?(Array) ? "#{segment.first}[]" : segment else segment.is_a?(Array) ? "[#{segment.first}][]" : "[#{segment}]" end end.join('') end |