Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

params as array for collection in a rails form #41

Open
estraver opened this issue Jan 29, 2017 · 0 comments
Open

params as array for collection in a rails form #41

estraver opened this issue Jan 29, 2017 · 0 comments

Comments

@estraver
Copy link

With a ralis form you can have parameter names with [] as in the next example

<input name="person[phone_number][]" type="text"/>
<input name="person[phone_number][]" type="text"/>
<input name="person[phone_number][]" type="text"/>

In params you receive an array. But in the deserialize! method it always expect a hash as you can see in the code below

    def rename_nested_param_for!(params, dfn)
      name        = dfn[:name]
      nested_name = "#{name}_attributes"
      return unless params.has_key?(nested_name)

      value = params["#{name}_attributes"]
      value = value.values if dfn[:collection]

      params[name] = value
    end

So maybe you can check if the received value is also an hash. values is not a method Array.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant