Home>

I am making a twitter demo app with reference to Progate.
When I press the new user registration button, the following error appears.

Routing Error
No route matches [GET] "/ users"
Corresponding source code
Rails.application.routes.draw do
  post "users/create" =>"users # create"
  get "signup" =>"users # new"
  get "users/index" =>"users # index"
  get "users /: id" =>"users # show"
  get'posts/index'=>'posts # index'
  get'posts/new'=>'posts # new'
  get'posts /: id'=>'posts # show'
  post'posts/create'=>'posts # create'
  get'posts /: id/edit'=>'posts # edit'
  post'posts /: id/update'=>'posts # update'
  post'posts /: id/destroy'=>'posts # destroy'
  get'/' =>'home # top'
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
class UsersController</pre>
<pre><code data-language = "Ruby">
  
     New user registration 
    
      
      <% = form_tag ("/ users/create") do%>
        <p>username</p>
        <input name = "name">
        <p>Email address</p>
        <input name = "email">
        <input type = "submit" value = "new registration">
      <% end%>
      
    
  
What I tried

I tried searching for an error, but it didn't work.

After pressing the new user registration button, the above error appears, but the user registration itself has been completed. ..
There is no problem with the operation of new posts, user list, and user post screens.

Supplementary information (FW/tool version, etc.)

Rails 6.0.3.
ruby 2.7.0

  • Answer # 1

    Routs about users

    get "users/index" =>"users # index"
    get "users /: id" =>"users # show"
    Since there is only one, "/ users" is undefined.

    get "users/index" =>"users # index"

    Is usually
    get "users" =>"users # index"
    So then the error disappears.

    I think it's better to use resouces

Related articles