Sha256: 54a60944ec1ce20b5f313614c443a2b01804bbc20cd556d770e926bfef5faf89
Contents?: true
Size: 709 Bytes
Versions: 13
Compression:
Stored size: 709 Bytes
Contents
module DependentFieldsFrameHelper def accept_query_string_override_for(form, method) field_name = form.field_name(method) new_value = new_value_from_query_string(field_name) return if new_value.nil? form.object.send(:"#{method}=", new_value) end private def new_value_from_query_string(field_name) params.dig(*params_dig_path_for_field_name(field_name)) end def params_dig_path_for_field_name(field_name) dig_path = [] nested_keys = Rack::Utils.parse_nested_query(field_name) while !nested_keys.nil? && nested_keys.keys.size key = nested_keys.keys.first dig_path << key.to_sym nested_keys = nested_keys[key] end dig_path end end
Version data entries
13 entries across 13 versions & 1 rubygems