Question: i'm working on laravel 5.7 
and i need a script to add new form when clicked plus button 

i found this script but its only add input fields i need to add the whole form 

```
 $(document).ready(function () {
        var max_fields = 10; //maximum input boxes allowed
        var wrapper = $(".input_fields_wrap"); //Fields wrapper
        var add_button = $(".add_field_button"); //Add button ID

        var x = 1; //initlal text box count
        $(add_button).click(function (e) { //on add input button click
            e.preventDefault();
            if (x < max_fields) { //max input box allowed
                x++; //text box increment
                $(wrapper).append('<div id="post"><input type="text" name="options[]" class="form-control"><input type="text" name="options[]" class="form-control"></div><br>'); //add input box
            }
        });

```

Answer: 
The error message you provided states:

```
No route matches {:action=>"show", :controller=>"attachments_controller", :id=>17}

```

The routes file you provided shows the routes you created:

```
resources :attachments, only: [:index, :new, :create, :destroy]
get "attachments/show" => "attachments#show"

```

Running rake routes will show that you've created the 4 routes in the first line, plus a route that responds to 'attachments/show'. If you really want to define the route like this, you should try:

```
get "attachments/:id", to: "attachments/show"

```

Your first route only responds to the word show, and would supply no params. The last route will take whatever comes after attachments, and pass it to the show action of the attachments controller as a paramater called 'id'.

Of course the easiest way to do all of that is to get rid of it all, and simply change the first route to:

```
resources :attachments, only: [:index, :new, :create, :destroy, :show]

```

Letting rails create the show route for you is exactly the same as manually defining it, and obviously reads a lot better
change

```
<%= image_tag url_for(:controller => "attachments_controller", :action => "show", :id => @attachment.id) %>

```

to

```
<%= image_tag url_for(:controller => "attachments", :action => "show", :id => @attachment.id) %>

```