How do I create a form that allows users to add additional instances of the same field if needed

Let’s say I wanna let users add all their pet’s on the same form but I don’t know how many pets they have I need to let the user provide values for multiple attributes for each pet but won’t be creating a pet’s table Rather, on completion going to create a text list of the users pets How would I do this?

You _could_ do this, but it's going to be a lot of trouble. Is there a reason why you don't want to add a pets table (and Pet model)? Then it would simply be a matter of adding a couple lines to your User model, and changing the users/_form partial to be a nested form.

class User < ApplicationModel   has_many :pets   accepts_nested_attributes_for :pets   ...

class Pet < ApplicationModel   belongs_to :user   ...

Walter

You could also use Chosen: A jQuery Plugin by Harvest to Tame Unwieldy Select Boxes

or

this jquery tokeninput - Adding a tag if it doesn't exist in rails chosen rails - Stack Overflow

google a little around I know I have done this a long time ago and it wasn’t that hard.

Thanks Walter, that’s what I did for now I’ve seen this in android adding contact’s phone numbers, you can keep pressing the new button and it adds a field set for you to put the number and type (home,work,mobile…)