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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:28:09+00:00 2026-05-19T04:28:09+00:00

My overall use case: I have a Listing model that has many images .

  • 0

My overall use case:

I have a Listing model that has many images. The Listing detail page lists all the fields that can be updated inline (through ajax).

I want to be able to use the same view for both update listing and create new listing.

My listing controller looks as follows:

 def detail 
     @listing = Listing.find(params[:id])  
     @image = Image.new #should this link somewhere else?

     respond_to do |format| 
         format.html # show.html.erb  
         format.xml { render :xml => @listing } 
      end 
 end 


  def create
      # create a new listing and save it immediately. Assign it to guest, with a status of "draft"
      @listing = Listing.new(:price_id => 1)  # Default price id
      # save it to db
      # TODO add validation that it has to have a price ID, on record creation. So the view doesn't break.
      @listing.save
      @image = Image.new

      # redirect_to "/listings/detail/@listing.id" #this didn't work

      respond_to do |format| 
          format.html # show.html.erb  
          format.xml { render :xml => @listing } 
      end
 end 

The PROBLEM
I’m using a partial that shows the same form for the create view and the detail view.

This works perfectly except for one thing:
When I pull up
http://0.0.0.0:3000/listings/detail/7, it works perfectly.

When I pull up
http://0.0.0.0:3000/listings/new, I get the following error:

Showing /Applications/MAMP/htdocs/rails_testing/feedbackd/app/views/listings/_edit_form.html.erb where line #100 raised:

No route matches {:action=>”show”, :controller=>”images”}
Extracted source (around line #100):

97: <!-- Form for new images -->
98: <div class="span-20 append-bottom">
99: <!-- <%# form_for :image, @image, :url => image_path, :html => { :multipart => true } do |f| %> -->
100: <%= form_for @image, :url => image_path, :html => { :multipart => true } do |f| %>
101:     <%= f.text_field :description %><br />
102:  <%= f.file_field :photo %>
103:  <%= submit_tag "Upload" %>

What I think the issue is:
When I upload a new image (I’m using Paperclip), it requires the listing_id to create the image record. Since the listing_id isn’t passed in with listings/new it can’t find the listing_id. How can I pass in the id? Via a redirect? What’s the best way to solve this? Thank you.

  • 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-19T04:28:10+00:00Added an answer on May 19, 2026 at 4:28 am

    Thank you, your comments have all been helpful.

    This is how I wound up solving it:

    I added a route for images/new to point to imageController -> Create

    <%= form_for @image, :url => "/images/new/#{@listing.id}" , :html => { :multipart => true } do |f| %>
    <%= f.text_field :description %><br />
    <%= f.file_field :photo %>
    <%= submit_tag "Upload" %>
    

    <% end %>

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

Sidebar

Related Questions

First of all, I don't have multiplication, division operations so i could use shifting/adding,
We have a SQL 2000 server that has widely varied jobs that run at
I have the following command which will loop over all the subdirectories in a
We have to automate database updation couple of times a month. My current use
I'll just start with the use case. Say I'm searching for a product with
I have a project which I would like to make more use of smart
Can anyone comment on the decision to use sprites for images or not? I
I'll describe my overall goal in case the question I asked isn't in the
I have an application that is on .net 2.0 and I am having some
whats the exact use of static variables in overall programming in .net and for

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.