Andres
Andres

Reputation: 11747

How to accept multiple objects as an array in simple_form without associated objects

I need to do something similar to the gif example I'm posting. I'm using simple form and I have seen tons of examples on how to add associated objects, but the catch is that the array that I want to get in the controller "entries" is not an association, nor a property. I just need to receive something like this in the controller:

{:entries=>["first", "second", "third"]}

Any clue/blog post or anything? I'm completely lost!

Sample

Upvotes: 1

Views: 498

Answers (1)

drummman
drummman

Reputation: 41

You can achieve this by adding a [ ] next to the input name. In your case:

<input type="text" name="entries[]">

Your controller will receive :entries param as an array with all the values of the inputs with name "entries[]" inside.

Upvotes: 1

Related Questions