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

  • Home
  • SEARCH
  • 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 6195927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:33:19+00:00 2026-05-24T03:33:19+00:00

I am trying to achieve a subsequent form submission. To clarify things – I

  • 0

I am trying to achieve a subsequent form submission. To clarify things –

  • I submit a form for @post
  • then once that @post is created I would immediately (under the hood) like to submit the form for @associations.
  • The catch is, this second form submission would require the post_id field from the newly created @post.

What would be the best way to achieve this? Would nested forms help me pull the newly created @post.id? Kindly help me with this.

  • 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-24T03:33:21+00:00Added an answer on May 24, 2026 at 3:33 am

    If this is something that should happen whenever you create a Post, then you should use active callbacks to achieve that :

    class Post < ActiveRecord::Base
    
      after_create do |post|
        # create your association using post.id
      end
    
    end
    

    or, you can write it like that also :

    class Post < ActiveRecord::Base
    
      after_create :after_create_post
    
      def after_create_post
        # create your association using self.id
      end
    
    end
    

    Otherwise, if this is something specific to a controller action, you should simple do something like this :

    class PostsController < ApplicationController
    
      def create
        @post = current_user.posts.build(params[:post])
        # then use the @post.id to build your association. something like
        @post.associations.build(:prop1 => 'value1', :prop2 => 'value2')
      end
    
    end
    

    Hope this helps!

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

Sidebar

Related Questions

What I am trying to achieve is a form that has a button on
What I'm trying to achieve is to determine if the Postscript that I'm parsing
I am trying to achieve the same behavior as indicated in the following post.
im trying to achieve the following, in php i have a form like this:
I'm trying to achieve the following functionality. Within a form I have multiple fields
What I'm trying to achieve is that a widget could exist in two different
im trying to achieve something that i thought it was easy, but the reality
Im trying to achieve a design that has five columns with fluid width, but
Trying to achieve a background on a page that is "split in two"; two
Am trying to achieve a couple of things: merge a bunch of individual text

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.