title: Create new user programmatically with Devise
body: <p>I'm using Devise to manage users in my rails app. I have a button available to admin users which leads to a form that allows them to create other admin user accounts.</p>
  
  <p>When the form is submitted this code is called:</p>
  
  <pre><code>@user = User.new(:email =&gt; params[:email], :password =&gt; params[:password], :password_confirmation =&gt; params[:password_confirmation])
  @user.admin = true
  @user.save
  </code></pre>
  
  <p>It doesn't seem to be working correctly as when I sign out and try to sign in with the new admin account it fails. I'm guessing the above code isn't the correct way to create a new user with Devise.</p>
  
  <p>Edit:</p>
  
  <p>Logs</p>
  
  <pre><code>Started POST "/users/13/create_admin" for 127.0.0.1 at 2013-07-16 17:01:38 +0100
  Processing by UsersController#create_admin as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"VpP78Zy8SAcyC1Mgg6hEjG2I5jqNzIHXQGtbjUzDYVE=", "users"=&gt;{"email"=&gt;"test@admin.com", "password"=&gt;"[FILTERED]", "password_confirmation"=&gt;"[FILTERED]"}, "commit"=&gt;"Sign up", "id"=&gt;"13"}
    User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 13 LIMIT 1
     (0.3ms)  BEGIN
     (0.1ms)  ROLLBACK
    Rendered users/create_admin.html.erb within layouts/application (0.0ms)
  Completed 200 OK in 12ms (Views: 5.3ms | ActiveRecord: 0.9ms)
  </code></pre>
  
  <p>Here's my form:</p>
  
  <pre><code>  &lt;%= form_for :users, :html =&gt; { :id =&gt; "signup-form" }, :url =&gt; create_admin_user_path do |f| %&gt;
  &lt;div&gt;&lt;%= f.label :email %&gt;
  &lt;%= f.email_field :email, :autofocus =&gt; true %&gt;&lt;/div&gt;
  
  &lt;div&gt;&lt;%= f.label :password %&gt;
  &lt;%= f.password_field :password %&gt;&lt;/div&gt;
  
  &lt;div&gt;&lt;%= f.label :password_confirmation %&gt;
  &lt;%= f.password_field :password_confirmation %&gt;&lt;/div&gt;
  
  &lt;div class="actions"&gt;
    &lt;div&gt;&lt;%= f.submit "Sign up", :class =&gt; "btn btn-success" %&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>