Sha256: ab395996d2896394e064dc8b166be64340b31d90eb376ea574a7bdbe18039f99
Contents?: true
Size: 691 Bytes
Versions: 18
Compression:
Stored size: 691 Bytes
Contents
module RefreshFieldsHelper 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[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
18 entries across 18 versions & 1 rubygems