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

  • Home
  • SEARCH
  • 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 9065005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:23:48+00:00 2026-06-16T16:23:48+00:00

I am working on a rails app, and have generated a Controller via rails

  • 0

I am working on a rails app, and have generated a Controller via

rails g controller Pics index upload

but now I would like to add another action

delete

do I do this by manually adding a delete method in the Pics controller?

Or do I need to run another generation. My concern is that by adding manually something may not get included (not sure what it would be, but something under the hood.)

Is this the best way of adding a new action to a generated controller?

  • 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-06-16T16:23:49+00:00Added an answer on June 16, 2026 at 4:23 pm

    If you add manually, just make sure you have the right route on your routes.rb.
    Let’s say you create your delete action inside your Pics controller.

    def delete
      # do stuff
    end
    

    On your routes.rb, you need to append the route to your resource like this, remembering to analyse if it is a resource that acts upon a member of your resource, or a collection. (More about this you can read on this guide http://guides.rubyonrails.org/routing.html#adding-more-restful-actions).

    resource :pics do
      collection do
        post :delete
      end
    end
    

    Or

    resource :pics do
      member do
        post :delete
      end
    end
    

    Remember that all RESTFUL actions are handled by default by the rails router, again, try to read the guide i showed earlier for precise information about the topic. Hope it helps.

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

Sidebar

Related Questions

I have rails app which are working perfectly in the local computer. But when
I have a simple search working in my rails app, but it only searches
I have a rails app with working reports that have tags. In the Report/Index.html.erb
I have been working on a rails app for a while now and want
I have a fantasy football league rails app that was working last year and
I have a rails app running on passenger standalone, which is working perfectly. I
I am working at a web app in Rails that behaves much like a
I'm working on unit tests for my Rails app and have run into the
I have multiple users working on a rails app in my Ubuntu machine with
I have an app that I was first writing in rails 3.1 but in

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.