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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:44:34+00:00 2026-05-24T05:44:34+00:00

What is the appropriate respond_with line for a nested resources destroy action? My routes:

  • 0

What is the appropriate respond_with line for a nested resources destroy action?

My routes:

resources :vendors do
  resources :products, :except => [:index]
end

Product#destroy (note @vendor and @product are found with a before_filter which is omitted here)

def destroy
  @product.destroy 
  respond_with @vendor, @product
end

According to my functional tests, this is returning /vendors/X/products/X and not /vendors/X

Should I change it to just responed_to @vendor?

  • 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-24T05:44:35+00:00Added an answer on May 24, 2026 at 5:44 am

    I believe Rails is smart enough to understand what to do if @product is destroyed

    respond_with [@vendor, @product]
    

    if not, then try this

    respond_with @product, :location => vendor_path(@vendor)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When is it appropriate to use an unsigned variable over a signed one? What
Is it ever appropriate to abandon the getMyValue() and setMyValue() pattern of getters and
What's the most appropriate type used to store the duration time information of a
One of the appropriate uses for sqlite3 is in-memory databases. This sounds like a
When is it appropriate to use <cflock scope=application> or it's ilk as opposed to
What is the most appropriate media type (formally MIME type) to use when sending
When is it appropriate to use CoTaskMemAlloc? Can someone give an example?
When is it appropriate to use openGl-es on the iPhone versus other toolkits? I
When is it appropriate to use connection pooling and what happens when the maximum
Which is appropriate: class xyz { static int xyzOp1() { } static int xyzOp2()

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.