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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:10:39+00:00 2026-05-27T19:10:39+00:00

I have a List object, with nested Tasks. I have created a page that

  • 0

I have a List object, with nested Tasks. I have created a page that displays individual tasks, and also a page that allows a user to edit individual tasks. I now want to add the ability to delete a task from a list on the tasks edit page. Using the following code

<%= link_to 'Delete this task',@task, confirm: 'Are you sure?', method: :delete %>

yields

undefined task_path method

This code is on the show.html.erb page, where I call @task to display all of the data stored within the task, so I believe that this issue may be a routing error of some kind, however I cannot seem to figure it out.

The related controller method is

def destroy
    @task = Task.find(params[:id])
    @task.destroy

    respond_to do |format|
        format.html { redirect_to list_tasks_path(@task) }
        format.json { head :ok }
    end
end

I thought that with the delete method the @task I supplied would just be sent to the destroy method via params, but this error seems to be showing that this isn’t exactly how it works. So how can I properly destroy a nested resource in Rails?

edit:
Here is the route file with nested resources:

MyApp::Application.routes.draw do
    resources :lists do
        resources :tasks
    end
    get "home/index"

    root :to => 'home#index'
end

Thank you for your help!

  • 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-27T19:10:40+00:00Added an answer on May 27, 2026 at 7:10 pm

    You should have @list setup, or use @task.list (assuming you have a belong to relationship), and you could do the following:

    <%= link_to "Delete this task", list_task_path(@task.list, @task), confirm: "Are you sure?", method: :delete %>
    

    Cheers!

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

Sidebar

Related Questions

Let's say I have a List object and an iterator for that list. Now
I have a nested repeater control that displays a list of data, in my
Embedded custom-tag in dynamic content (nested tag) not rendering. I have a page that
Suppose you have a list of 100 complex nested object, and you want to
Hi: In my jsp page,I have a form to add/update a nested object using
If I have an object that is composed of nested complex types, e.g. a
I have a List object being accessed by multiple threads. There is mostly one
I have a list of object I wish to sort in C#.Net 3.5, the
I have a List of object, produced by JPA q.getResultList() . I would like
I have an object list being loded from a database to a drop down

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.