Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5984457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:22:42+00:00 2026-05-22T22:22:42+00:00

when I do rails g model user name:string rails g controller users index create

  • 0

when I do

rails g model user name:string
rails g controller users index create new destroy show

and edit config/routes.rb to add:

resource :users

bundle exec rake routes gives:

     users POST   /users(.:format)      {:action=>"create", :controller=>"users"}
 new_users GET    /users/new(.:format)  {:action=>"new", :controller=>"users"}
edit_users GET    /users/edit(.:format) {:action=>"edit", :controller=>"users"}
           GET    /users(.:format)      {:action=>"show", :controller=>"users"}
           PUT    /users(.:format)      {:action=>"update", :controller=>"users"}
           DELETE /users(.:format)      {:action=>"destroy", :controller=>"users"}

however, when I do

rails g resource users name:string

(which automatically adds resources :users to config/routes.rb)
bundle exec rake routes

I get

    users GET    /users(.:format)          {:action=>"index", :controller=>"users"}
          POST   /users(.:format)          {:action=>"create", :controller=>"users"}
 new_user GET    /users/new(.:format)      {:action=>"new", :controller=>"users"}
edit_user GET    /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
     user GET    /users/:id(.:format)      {:action=>"show", :controller=>"users"}
          PUT    /users/:id(.:format)      {:action=>"update", :controller=>"users"}
          DELETE /users/:id(.:format)      {:action=>"destroy", :controller=>"users"}

So my question is,

when I generate a controller how can I get the correct helper methods to make
link_to ‘Destroy’, instance, :method=> :delete
work?

Because currently it gives an error user_path is not defined.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:22:43+00:00Added an answer on May 22, 2026 at 10:22 pm

    You should call

    rails g controller user index create new destroy show
    

    instead of

    rails g controller users index create new destroy show
    

    in order to get resources :users to give you the helpers you want.

    The latter causes Rails to assume that users is a singular object, and that resources :users should create what is called a singular resource:

    http://guides.rubyonrails.org/routing.html#singular-resources

    as a result, user_path is undefined, whereas users_path is defined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

rails 3 rspec-rails 2 In controller: def index @users = User.paginate :page => params[:page],:per_pae
My Rails 2.3 application has a User model and the usual controller actions. The
I created a rails model by doing script/generate model Customer name:string address:string city:string state:string
I have a rails model User that has name , email and hash fields.
Rails 2.3.3 Database and Model Schema User (id,name,email) posts (id,subject,message,user_id) How can I display
I created a routing test rails3 app with one model 'User': rails new routing_test_app
In a typical User - Post - Comment model in Rails, every user can
Both my Rails model and controller code need to write files to the file
I've got a word model in my rails app. In the index action of
I want to make a language selection dropdown in a site user edit/create page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.