Note that there are some explanatory texts on larger screens.

plurals
  1. POAutopopulating a sign up form with params from pre-registration form not working
    primarykey
    data
    text
    <p>so I'm trying to build a sign-up process just like <a href="http://www.twitter.com" rel="nofollow">Twitter</a> has. Meaning, there's a pre-sign up form which leads to full form with autopopulated fields from the first form. I'm trying to create this using <code>:value =&gt; @name</code> in the final form, but it's not working and I just can't figure out why.</p> <p>Here's my code, simplified:</p> <p><strong>First form, controller: public_controller, action: index (root_path)</strong></p> <pre><code>&lt;%= form_tag({:controller =&gt; "users", :action =&gt; "register"})%&gt; &lt;input name="user[name]" type="text" /&gt; &lt;input name="user[email]" type="text"/&gt; &lt;input name="user[password]" type="password"/&gt; &lt;input name="commit" type="submit" value="Sign Up!" /&gt; </code></pre> <p><strong>Second form, controller: users_controller, action: register (/signup)</strong></p> <pre><code> &lt;%= form_for(:user, :url =&gt; { :controller =&gt; 'users', :action =&gt; 'create' }) do |f| %&gt; &lt;%= f.text_field :name, :value =&gt; @name %&gt; &lt;%= f.text_field :email, :value =&gt; @email %&gt; &lt;%= f.password_field :password, :value =&gt; @password %&gt; &lt;input name="commit" type="submit" value="Sign Up!" /&gt; &lt;% end %&gt; </code></pre> <p><strong>Users_controller</strong></p> <pre><code>def register @name = params[:name] @email = params[:email] @password = params[:password] end </code></pre> <p><strong>The params are passing to the final form page (/signup)</strong></p> <p>{"utf8"=>"✓", "authenticity_token"=>"R3wVNHvqpDBi1Lg69lwKu4NeQGjA12oV/Aytw38OeHc=", "user"=>{"name"=>"Stackoverflow", "email"=>"stack@stackstack.com", "password"=>"stacker", "password_confirmation"=>"stacker"}, "commit"=>"Sign Up!", "search"=>"", "controller"=>"users", "action"=>"register"}</p> <p>But they are not autopopulating the final form's fields.</p> <p>I've also tried using <code>:input_html =&gt; { :value =&gt; @name }</code> with <code>params[:name]</code>, but it has no effect, and the input's value simply turns to value="nil".</p> <p>I just can't think of anything else to try from here. Any ideas? Thanks in advance! Any help is greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload