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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:22:03+00:00 2026-05-14T19:22:03+00:00

I have an interesting situation, well it’s probably not that unique at all, but

  • 0

I have an interesting situation, well it’s probably not that unique at all, but I’m not totally sure how to tackle it. I have a model, in this case a recipe and the user navigates to the new path /recipes/new however the situation is that I need to be able to have the user upload images and make associations to that model in the new action, but the model doesn’t have an ID yet.

So I assume I need to rethink my controller, but I don’t want to have redirects and whatnot, how can accomplish this?

Here is the basic controller, barebones obviously:

...

def new
  # I should be creating the model first, so it has an ID
  @recipe = Recipe.new
end

def create
  @recipe = Recipe.new(params[:recipe])
  if @recipe.save
    redirect_to @recipe
  else
    render 'new'
  end
end

...

update

Perhaps I can have a column thats like state which could have values like new/incomplete/complete or what-have-you. I’m mostly trying to figure out what would also be most efficient for the DB.

It would be nice if I could still have a url that said ‘/new’, instead of it be the edit path with the id, for usability sake, but I’m not sure this can be simply accomplished in the new action of my controller.

Thoughts?

  • 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-14T19:22:03+00:00Added an answer on May 14, 2026 at 7:22 pm

    I’m not sure if I understand you correctly, but:

    In new action you can create new object and attach files to it and post it in one form. You don’t have to have it stored in db at this point. It can be saved in create action like any other fileds in model. In this case field “name” and “attached_file” (just examples) are treated in the same way (almost). Take a look at some paperclip (or whatever) tutorial in the web.

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

Sidebar

Related Questions

I have an interesting situation where certain things are working but others are not
I have an interesting situation on my hands, and I'm not quite sure how
I have an interesting situation that EMF forced me into: abstract class AbstractDog{ ...
I have an interesting situation that has me stumped. It seems that posting appliction/json
I have this interesting situation. I have a bunch of structs that hold a
Interesting situation. I have a section of code that creates several ZipOutputStreams. As a
Related but not quite what I am looking for merge-two-branches-what-direction. Situation: I have inherited
I have an interesting situation that my usually clever mind hasn't been able to
I have a interesting situation that I want to see if there is a
Hi folks hi have a very interesting situation. i have a viewmodel that requires

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.