Home>
No information sent to database

Using rails on ruby, send the information entered in the posting form to the database,
If the data is saved, it will be transferred to the list page,
I am making a page that repeats the posting form if it is not saved.

Even if I press the submit button from the post form, the data is not submitted
I will be returned to the post form.
The input contents are properly sent to the database,
I want to be able to display it.

I don't get an error message,
When I checked with rails c, there was no information in the database.

Corresponding source code
New coat post<% = link_to "Return to coat list", coats_path%><p>Post form</p><% = form_for (@coat,: url =>{controller:'coats', action:'create'}) do | f |%>    <% = f.label: Court name%>    <% = f.text_field: name, size: 140%>    <br>                <% = f.label: image%>        <% = f.file_field: image%>            <% = f.label: Address%>    <% = f.text_field: address, size: 140%>    <br>    <% = f.label: Details%>    <% = f.text_field: body, size: 140%>    <br>    <% = f.label: Link%><% = f.text_field: url, size: 140%>    <br><% = f.submit "submit"%><br><% end%>
class CoatsController  "index"
        else else
            redirect_to: action =>"new"
        end
    end
...abridgement...
privatedef coat_params
        params.require (: coat) .permit (: name,: address,: url,: body,: image)
    end
end
class CreateCoats</pre>
<pre><code data-language = "railsroutes">                             Prefix Verb URI Pattern Controller # Action
                     new_user_session GET/users/sign_in (.: format) devise/sessions # new
                         user_session POST/users/sign_in (.: format) devise/sessions # create
                 destroy_user_session DELETE/users/sign_out (.: format) devise/sessions # destroy
                    new_user_password GET/users/password/new (.: format) devise/passwords # new
                   edit_user_password GET/users/password/edit (.: format) devise/passwords # edit
                        user_password PATCH/users/password (.: format) devise/passwords # update
                                      PUT/users/password (.: format) devise/passwords # update
                                      POST/users/password (.: format) devise/passwords # create
             cancel_user_registration GET/users/cancel (.: Format) devise/registrations # cancel
                new_user_registration GET/users/sign_up (.: format) devise/registrations # new
               edit_user_registration GET/users/edit (.: format) devise/registrations # edit
                    user_registration PATCH/users (.: format) devise/registrations # update
                                      PUT/users (.: format) devise/registrations # update
                                      DELETE/users (.: format) devise/registrations # destroy
                                      POST/users (.: format) devise/registrations # createuser GET/users /: id (.: format) users # show
                           coat_likes POST/coats /: coat_id/likes (.: format) likes # create
                            coat_like DELETE/coats /: coat_id/likes /: id (.: format) likes # destroy
                                coats GET/coats (.: format) coats # index
                                      POST/coats (.: format) coats # create
                             new_coat GET/coats/new (.: format) coats # new
                            edit_coat GET /coats/:id/edit(.:format) coats # edit
                                 coat GET/coats /: id (.: format) coats # show
                                      PATCH/coats /: id (.: format) coats # update
                                      PUT/coats /: id (.: format) coats # update
                                      DELETE/coats /: id (.: format) coats # destroy
                                users GET/users (.: format) users # index
                                      POST/users (.: format) users # create
                             new_user GET/users/new (.: format) users # new
                            edit_user GET/users /: id/edit (.: format) users # edit
                                      GET/users /: id (.: format) users # show
                                      PATCH/users /: id (.: format) users # update
                                      PUT/users /: id (.: format) users # update
                                      DELETE/users /: id (.: format) users # destroy
                              statics GET/statics (.: format) statics # index
                                      POST/statics (.: format) statics # create
                           new_static GET/statics/new (.: format) statics # new
                          edit_static GET/statics /: id/edit (.: format) statics # edit
                               static GET/statics /: id (.: format) statics # show
                                      PATCH/statics /: id (.: format) statics # update
                                      PUT/statics /: id (.: format) statics # update
                                      DELETE/statics /: id (.: format) statics # destroy
                                 root GET/coats # index
Supplementary information (FW/tool version, etc.)

Mostly copied and pasted from other similar apps (made by myself)

  • Answer # 1

    There is no error message because I didn't make it appear in the view.
    It's a good idea to temporarily change if @ coat.save to if @ coat.save! And check the error details.

  • Answer # 2

    I've found a lot of deficiencies and I'm going to start over, thank you to all the people who gave me advice.

  • Answer # 3

    I have found many deficiencies and will start over from the beginning, thank you to all the people who gave me advice.

Related articles