title: Rails 5 - Best way to hold onto params for creating associations?
body: <p>Here's the scenario to illustrate my question. I have 2 models:</p>
  
  <pre><code># models/post.rb
  
  belongs_to :user
  validates_presence_of :comment
  </code></pre>
  
  <p>And we have a devise model called Users</p>
  
  <pre><code># models/user.rb
  
  has_many :posts
  </code></pre>
  
  <p>What I would like to achieve:</p>
  
  <p>Person comes to the website, is able to create a <code>Post</code>, after creating the <code>Post</code>, they are prompted to create an account. After creating the account, the <code>Post</code> that they just created would be associated to the <code>User</code> they just created.</p>
  
  <p>Usually i'd make use of routes to hold the <code>params[:id]</code> which can be accessed in the controller method. For example the URL may look something like this:</p>
  
  <p><code>www.foo.com/foo/new/1</code></p>
  
  <p>And then I can do this:</p>
  
  <pre><code># foo_controller.rb
  
  def new
    @foo = Foo.new
    @parent = Parent.find(params[:id])
  end
  </code></pre>
  
  <p>And in the view I can simply access <code>@parent</code> and use a hidden field to fill the parent ID.</p>
  
  <p>But when routing through so many different pages (such as creating a Devise User), how do I hold onto the parent/child ID such that I can still create that association?</p>