title: Editing user details creates new user. Devise, Rails 4
body: <p>I have weird problem, previous created form instead of updating user details such as e-mail or name  creates new user with given details.</p>
  
  <p><strong>My form:</strong>
  this code example I took from <strong><em>views/devise/registrations/edit</em></strong> </p>
  
  <pre><code>&lt;%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { "data-parsley-validate" =&gt; true, :id=&gt;"user-edit"},remote: true, format: :json) do |f| %&gt;   
  
      &lt;div class="form-group"&gt;
          &lt;%= f.text_field :name,:class=&gt;"user-input form-control", :id=&gt;"user-name" ,:placeholder=&gt; "Lietotājvārds*",:"data-parsley-group"=&gt;"f1" %&gt;               
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;    
          &lt;%= f.email_field :email ,:class=&gt;"user-input form-control", :id=&gt;"password",:placeholder=&gt; "E-pasts *",:"data-parsley-group"=&gt;"f2" %&gt;                            
      &lt;/div&gt;   
  
      &lt;div class="form-group"&gt;                  
          &lt;%= f.password_field :current_password, :autocomplete =&gt; "off"  ,:class=&gt;"user-input form-control", :id=&gt;"password",:placeholder=&gt; "Vecā parole*                       ",:"data-parsley-group"=&gt;"f3" %&gt;  
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;                      
          &lt;%= f.password_field :password , :class=&gt;"user-input form-control", :id=&gt;"password",:placeholder=&gt; "Jaunā parole*                       vismaz 8 simboli ",  :"data-parsley-group"=&gt;"f3" %&gt;  
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;                        
         &lt;%= f.password_field :password_confirmation , :class=&gt;"user-input form-control", :id=&gt;"password",:placeholder=&gt; "Atkārtot paroli *                     vismaz 8 simboli ",  :"data-parsley-group"=&gt;"f3" %&gt;      
      &lt;/div&gt;
  
      &lt;button type="submit" class="blue-button btn btn-default"&gt;Apstiprināt&lt;/button&gt;
  &lt;%end%&gt;
  </code></pre>
  
  <p><strong>Routes file:</strong></p>
  
  <pre><code> devise_for :users,  :controllers =&gt; {:registrations=&gt; "registrations"}
  </code></pre>
  
  <p><strong>Registration controller:</strong></p>
  
  <pre><code>class RegistrationsController &lt; Devise::RegistrationsController 
  
      clear_respond_to   
      respond_to :json
  
     def sign_up_params
      params.require(:user).permit( :email, :password, :password_confirmation,:name, :not_a_robot,:current_password,:bypass_humanizer)
    end
    def account_update_params
      params.require(:user).permit(:name, :email, :password, :password_confirmation, :current_password, :not_a_robot, :bypass_humanizer)
    end
    private :sign_up_params
    private :account_update_params
  
  
    protected
  
    def update_resource(resource, params)
      resource.update_without_password(params)
    end
  
  end
  </code></pre>
  
  <p><strong>In applicaion helper:</strong></p>
  
  <pre><code>module ApplicationHelper
       def resource_name
      :user
    end
  
    def resource
      @resource ||= User.new
    end
  
    def devise_mapping
      @devise_mapping ||= Devise.mappings[:user]
  
    end
  
  end
  </code></pre>
  
  <p><strong>Log file:</strong> </p>
  
  <pre><code>   Started POST "/ru/users" for 85.255.65.15 at 2015-09-28 19:32:25 +0300
      Processing by RegistrationsController#create as JS
        Parameters: {"utf8"=&gt;"✓", "user"=&gt;{"name"=&gt;"ooppapa", "email"=&gt;"test11@!!!", "current_password"=&gt;"[FILTERED]", "password"=&gt;"[FILTERED]", "password_confirmation"=&gt;"[FILTERED]", "bypass_humanizer"=&gt;"true", "not_a_robot"=&gt;"1"}, "locale"=&gt;"ru"}
        [1m[36mBanlist Load (2.0ms)[0m  [1mSELECT `banlists`.* FROM `banlists`  WHERE (ip_adress = '85.255.65.15')[0m
        [1m[35mCountry Load (1.5ms)[0m  SELECT  `countries`.* FROM `countries`  WHERE `countries`.`id` = 1 LIMIT 1
        [1m[36mRegion Load (1.3ms)[0m  [1mSELECT `regions`.* FROM `regions`  WHERE `regions`.`country_id` = 1[0m
        [1m[35m (0.4ms)[0m  BEGIN
        [1m[36mUser Exists (44.1ms)[0m  [1mSELECT  1 AS one FROM `users`  WHERE `users`.`email` = BINARY 'test11@!!!' LIMIT 1[0m
        [1m[35mUser Load (24.3ms)[0m  SELECT  `users`.* FROM `users`  WHERE `users`.`confirmation_token` = '5c5e282bd4c139c7764506b785d54119ceee5499426b555c3650cfc7190ee947'  ORDER BY `users`.`id` ASC LIMIT 1
        [1m[36mSQL (2.1ms)[0m  [1mINSERT INTO `users` (`confirmation_sent_at`, `confirmation_token`, `created_at`, `email`, `encrypted_password`, `name`, `updated_at`) VALUES ('2015-09-28 19:32:29', '5c5e282bd4c139c7764506b785d54119ceee5499426b555c3650cfc7190ee947', '2015-09-28 19:32:28', 'test11@individualki.eu', '$2a$10$mEHajmY0H1NueGrrap7NNu0LuViDEJ.imAS4jhdj1KIyPRIyej/NC', 'ooppapa', '2015-09-28 19:32:28')[0m
        Rendered devise/mailer/confirmation_instructions.html.erb (29.2ms)
  
      Devise::Mailer#confirmation_instructions: processed outbound mail in 1726.8ms
  
      Sent mail to test11@!!!.eu (776.1ms)
      Date: Mon, 28 Sep 2015 19:32:31 +0300
      From: support@!!!!.eu
      Reply-To: support@!!!!.eu
      To: test11@!!!!.eu
      Message-ID: &lt;56096b9f98eb5_25e4640a718550c6@!!!!!&gt;
      Subject: Confirmation instructions
      Mime-Version: 1.0
      Content-Type: text/html;
       charset=UTF-8
      Content-Transfer-Encoding: 7bit
  
      &lt;p&gt;Welcome !!!&lt;/p&gt;
  
      &lt;p&gt;You can confirm your account email through the link below:&lt;/p&gt;
  </code></pre>
  
  <p><strong>My routes:</strong></p>
  
  <pre><code>rake routes
    new_user_session GET    (/:locale)/users/sign_in(.:format)                    devise/sessions#new {:locale=&gt;/lv|ee|ru/}
                    user_session POST   (/:locale)/users/sign_in(.:format)                    devise/sessions#create {:locale=&gt;/lv|ee|ru/}
            destroy_user_session DELETE (/:locale)/users/sign_out(.:format)                   devise/sessions#destroy {:locale=&gt;/lv|ee|ru/}
                   user_password POST   (/:locale)/users/password(.:format)                   devise/passwords#create {:locale=&gt;/lv|ee|ru/}
               new_user_password GET    (/:locale)/users/password/new(.:format)               devise/passwords#new {:locale=&gt;/lv|ee|ru/}
              edit_user_password GET    (/:locale)/users/password/edit(.:format)              devise/passwords#edit {:locale=&gt;/lv|ee|ru/}
                                 PATCH  (/:locale)/users/password(.:format)                   devise/passwords#update {:locale=&gt;/lv|ee|ru/}
                                 PUT    (/:locale)/users/password(.:format)                   devise/passwords#update {:locale=&gt;/lv|ee|ru/}
        cancel_user_registration GET    (/:locale)/users/cancel(.:format)                     registrations#cancel {:locale=&gt;/lv|ee|ru/}
               user_registration POST   (/:locale)/users(.:format)                            registrations#create {:locale=&gt;/lv|ee|ru/}
           new_user_registration GET    (/:locale)/users/sign_up(.:format)                    registrations#new {:locale=&gt;/lv|ee|ru/}
          edit_user_registration GET    (/:locale)/users/edit(.:format)                       registrations#edit {:locale=&gt;/lv|ee|ru/}
                                 PATCH  (/:locale)/users(.:format)                            registrations#update {:locale=&gt;/lv|ee|ru/}
                                 PUT    (/:locale)/users(.:format)                            registrations#update {:locale=&gt;/lv|ee|ru/}
                                 DELETE (/:locale)/users(.:format)                            registrations#destroy {:locale=&gt;/lv|ee|ru/}
               user_confirmation POST   (/:locale)/users/confirmation(.:format)               devise/confirmations#create {:locale=&gt;/lv|ee|ru/}
           new_user_confirmation GET    (/:locale)/users/confirmation/new(.:format)           devise/confirmations#new {:locale=&gt;/lv|ee|ru/}
                                 GET    (/:locale)/users/confirmation(.:format)               devise/confirmations#show {:locale=&gt;/lv|ee|ru/}
            update_password_user PATCH  (/:locale)/user/update_password(.:format)             users#update_password {:locale=&gt;/lv|ee|ru/}
                       edit_user GET    (/:locale)/user/edit(.:format)                        users#edit {:locale=&gt;/lv|ee|ru/}
                     sms_receive GET    (/:locale)/sms/receive(.:format)                      sms#receive {:locale=&gt;/lv|ee|ru/}
                            root GET    /(:locale)(.:format)                                  girls#index {:locale=&gt;/lv|ee|ru/}
  </code></pre>
  
  <p>I am confused. Is it registration_path(resource_name) that creates this error?</p>
  
  <p>Any advise could be helpful.!
  thanks in advance.</p>