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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:23:25+00:00 2026-05-25T14:23:25+00:00

I have a form where the model has a nested resource (an image uploaded

  • 0

I have a form where the model has a nested resource (an image uploaded with Carrierwave), and in the nested resource I have a link_to that allows the deletion of the image. Clicking the link removes the carrierwave item and deletes the image. This all works perfectly for the edit function, but when trying to go to the new screen I get the following error:

No route matches {:controller=>"listings", :action=>"remove_image"} 
(ActionView::Template::Error)

Here is the link in question:

    <%= link_to "Delete this image", remove_image_path(builder.object.id), 
        :confirm => "Are you sure you want to delete this image?", 
        :method => :delete %>

here is my routes entry:

match "/remove_image/:id" => "listings#remove_image", :as => "remove_image"

And here’s the method from the ListingsController:

def remove_image
  @image = SecondaryImage.find(params[:id])
  @listing = Listing.find(@image.listing_id)
  @image.remove_image
  @image.destroy
  respond_to do |format|
  format.html { redirect_to edit_listing_path(@listing), 
                notice: "Successfully deleted secondary image" }
  end 
end

UPDATE: Rake routes
As requested, here are the routes related to the ListingsController

   listing_secondary_images GET    /listings/:listing_id/secondary_images(.:format)          {:action=>"index", :controller=>"secondary_images"}
                            POST   /listings/:listing_id/secondary_images(.:format)          {:action=>"create", :controller=>"secondary_images"}
new_listing_secondary_image GET    /listings/:listing_id/secondary_images/new(.:format)      {:action=>"new", :controller=>"secondary_images"}
edit_listing_secondary_image GET    /listings/:listing_id/secondary_images/:id/edit(.:format) {:action=>"edit", :controller=>"secondary_images"}
 listing_secondary_image GET    /listings/:listing_id/secondary_images/:id(.:format)      {:action=>"show", :controller=>"secondary_images"}
                         PUT    /listings/:listing_id/secondary_images/:id(.:format)      {:action=>"update", :controller=>"secondary_images"}
                         DELETE /listings/:listing_id/secondary_images/:id(.:format)      {:action=>"destroy", :controller=>"secondary_images"}
                listings GET    /listings(.:format)                                       {:action=>"index", :controller=>"listings"}
                         POST   /listings(.:format)                                       {:action=>"create", :controller=>"listings"}
             new_listing GET    /listings/new(.:format)                                   {:action=>"new", :controller=>"listings"}
            edit_listing GET    /listings/:id/edit(.:format)                              {:action=>"edit", :controller=>"listings"}
                 listing GET    /listings/:id(.:format)                                   {:action=>"show", :controller=>"listings"}
                         PUT    /listings/:id(.:format)                                   {:action=>"update", :controller=>"listings"}
                         DELETE /listings/:id(.:format)                                   {:action=>"destroy", :controller=>"listings"}
                features GET    /features(.:format)                                       {:action=>"index", :controller=>"features"}
                         POST   /features(.:format)                                       {:action=>"create", :controller=>"features"}
             new_feature GET    /features/new(.:format)                                   {:action=>"new", :controller=>"features"}
            edit_feature GET    /features/:id/edit(.:format)                              {:action=>"edit", :controller=>"features"}
                 feature GET    /features/:id(.:format)                                   {:action=>"show", :controller=>"features"}
                         PUT    /features/:id(.:format)                                   {:action=>"update", :controller=>"features"}
                         DELETE /features/:id(.:format)                                   {:action=>"destroy", :controller=>"features"}
                  orders GET    /orders(.:format)                                         {:action=>"index", :controller=>"orders"}
                         POST   /orders(.:format)                                         {:action=>"create", :controller=>"orders"}
               new_order GET    /orders/new(.:format)                                     {:action=>"new", :controller=>"orders"}
              edit_order GET    /orders/:id/edit(.:format)                                {:action=>"edit", :controller=>"orders"}
                   order GET    /orders/:id(.:format)                                     {:action=>"show", :controller=>"orders"}
                         PUT    /orders/:id(.:format)                                     {:action=>"update", :controller=>"orders"}
                         DELETE /orders/:id(.:format)                                     {:action=>"destroy", :controller=>"orders"}
         preview_listing GET    /preview/:id(.:format)                                    {:controller=>"listings", :action=>"preview"}
         approve_listing        /approve/:id(.:format)                                    {:controller=>"listings", :action=>"approve"}
            remove_image        /remove_image/:id(.:format)                               {:controller=>"listings", :action=>"remove_image"}
  • 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-25T14:23:25+00:00Added an answer on May 25, 2026 at 2:23 pm

    How about simply doing this?

    <%= link_to "Delete this image", "/remove_image/#{builder.object.id}", 
        :confirm => "Are you sure you want to delete this image?", 
        :method => :delete %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got a form that have a nested link. The problem that the link
I have a project model that has_many :tasks . I added a nested resource
I have a nested model form that isn't functioning properly. The POST is to
I have a sign-up form that has nested associations/attributes whatever you want to call
I have an Organization model that has_many users through affiliations. And, in the form
I have a model form that contains a DecimalField() with max_digits set to 5.
I have a form that edits an instance of my model. I would like
Right now, I have more than 25 vertices that form a model. I want
I have a Django form that uses an integer field to lookup a model
if i have created a view model and have a partial form that is

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.