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 206429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:38:43+00:00 2026-05-11T17:38:43+00:00

Using a restful resource in Rails, I would like to be able to insert

  • 0

Using a restful resource in Rails, I would like to be able to insert a link into my flash hash that the user can click to destroy the object in question. The only problem seems to be that I cannot get the generated link to work with the RESTful controller!

First I tried

link_to "Change your reservation", reservation_path(@existing_reservation), :method => :delete

This didn’t work because link_to is a helper method in ActionView, not available in controllers

Next find was url_for

url_for :controller => 'reservations', :actions => 'destroy', :method => :delete

which took me back to the show action. I have tried every combination of the two that I can find . . . but I can’t seem to create a link in my controller that will slip in the delete method! Every action I generate produces a normal link (GET), which calls the show method.

Any ideas?

  • 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-11T17:38:43+00:00Added an answer on May 11, 2026 at 5:38 pm

    ApplicationController.helpers.link_to will allow you to use helper methods in the controllers, although I’m not sure that’s strictly following MVC. Although occasionally I’ve found a need, i.e. calling number_to_currency.

    Another problem arises when you use the :delete option in that particular helper. It will fail. After a quick glance at the source code I cant really see an immediate fix.

    Firstly, I would recommend you put the delete link somewhere else on that page if possible. If you really need it in the flash you could modify the flash in the view.

    I.e. in the controller setup the flash:

    flash[:notice] = "Flash message with a  DELETE LINK in it"
    

    Then in the view modify that flash before displaying it:

    <%=  flash[:notice].gsub(/DELETE LINK/, link_to("delete", resource_path, :method => :delete)) %>
    

    You would probably want to just make that into your own helper. If you don’t like gsub-ing the text like that I’m sure you could find another way, how about just appending the link to the flash?

    Hope that helps : )

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

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 94k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In order to support refactoring correctly (rename class), then you… May 11, 2026 at 6:54 pm
  • Editorial Team
    Editorial Team added an answer std::string has multiple constructors, one of which is string( const… May 11, 2026 at 6:54 pm
  • Editorial Team
    Editorial Team added an answer Referrers are not required. If a browser doesn't supply it… May 11, 2026 at 6:54 pm

Related Questions

I started a Rails project recently and decided to use RESTful controllers. I created
This is a more generic reformulation of this question (with the elimination of the
I'm currently working to specify my company's new partner/public API, which will be a
Our whole system is being designed around REST and are now considering how processes
I'm trying to learn how to build RESTful services with WCF by recreating the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.