]> git.openstreetmap.org Git - rails.git/commitdiff
Change user forms to use current user instead of @user
authorTom Hughes <tom@compton.nu>
Thu, 27 Jul 2017 18:40:20 +0000 (19:40 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 27 Jul 2017 18:40:20 +0000 (19:40 +0100)
app/controllers/user_controller.rb
app/views/user/account.html.erb
app/views/user/new.html.erb

index ea6e1a8d5d6fdbc5729f7e74e7f6d722f5b21e36..d3ed53c1bc040353d52d8b23884bf6decf13cd31 100644 (file)
@@ -220,6 +220,8 @@ class UserController < ApplicationController
       flash.now[:notice] = render_to_string :partial => "auth_association"
     else
       check_signup_allowed
+
+      self.current_user = User.new
     end
   end
 
index ab74e378079e2078dd602b079a1dbc421c6044f4..2e7f68d9d4dc2409e699934c5c00795ed073f1fd 100644 (file)
@@ -10,8 +10,8 @@
   </ul>
 <% end %>
 
-<%= error_messages_for 'user' %>
-<%= form_for :user, :html => { :multipart => true, :id => 'accountForm', :class => 'standard-form', :autocomplete => :off } do |f| %>
+<%= error_messages_for current_user %>
+<%= form_for current_user, :html => { :multipart => true, :id => 'accountForm', :class => 'standard-form', :autocomplete => :off } do |f| %>
   <fieldset>
     <div class="form-row">
       <label class="standard-label"><%= t 'user.new.display name' %></label>
@@ -92,7 +92,7 @@
   <fieldset class="form-divider">
     <div class='form-row'>
       <label class="standard-label"><%= t 'user.account.profile description' %></label>
-      <%= richtext_area :user, :description, :cols => 80, :rows => 20 %>
+      <%= richtext_area :user, :description, :object => current_user, :cols => 80, :rows => 20 %>
     </div>
 
     <div class="form-row">
index fcd775a484eca5046710e344a2ecdc92dce5fe3c..5a207060eeaf101548c6400f4f5b4808caf09ec3 100644 (file)
@@ -8,7 +8,7 @@
   <div class='header-illustration new-user-arm'></div>
 <% end %>
 
-<%= form_for :user, :url => { :action => 'create' }, :html => { :class => 'standard-form fillL col6 inner22' } do %>
+<%= form_for current_user, :url => { :action => 'create' }, :html => { :class => 'standard-form fillL col6 inner22' } do |f| %>
   <%= hidden_field_tag('referer', h(@referer)) unless @referer.nil? %>
 
   <fieldset>
       <label for="email" class="standard-label">
         <%= t 'user.new.email address' %>
       </label>
-      <%= email_field(:user, :email, { :tabindex => 1 }) %>
-      <%= error_message_on(:user, :email) %>
+      <%= f.email_field(:email, { :tabindex => 1 }) %>
+      <%= f.error_message_on(:email) %>
     </div>
     <div class="form-row">
       <label for="email_confirmation" class="standard-label">
         <%= t 'user.new.confirm email address' %>
       </label>
-      <%= email_field(:user, :email_confirmation, { :tabindex => 2 }) %>
-      <%= error_message_on(:user, :email_confirmation) %>
+      <%= f.email_field(:email_confirmation, { :tabindex => 2 }) %>
+      <%= f.error_message_on(:email_confirmation) %>
     </div>
     <span class="form-help deemphasize"><%= raw(t 'user.new.not displayed publicly') %></span>
   </fieldset>
@@ -34,8 +34,8 @@
       <label for="display_name" class="standard-label">
         <%= t 'user.new.display name' %>
       </label>
-      <%= text_field(:user, :display_name, { :tabindex => 3 }) %>
-      <%= error_message_on(:user, :display_name) %>
+      <%= f.text_field(:display_name, { :tabindex => 3 }) %>
+      <%= f.error_message_on(:display_name) %>
     </div>
     <span class="form-help deemphasize"><%= t 'user.new.display name description' %></span>
   </fieldset>
@@ -45,9 +45,9 @@
       <label for="openid_url" class="standard-label">
         <%= raw t 'user.new.external auth' %>
       </label>
-      <%= select(:user, :auth_provider, Auth::PROVIDERS, { :default => "", :tabindex => 4 }) %>
-      <%= text_field(:user, :auth_uid, { :tabindex => 5 }) %>
-      <%= error_message_on(:user, :auth_uid) %>
+      <%= f.select(:auth_provider, Auth::PROVIDERS, { :default => "", :tabindex => 4 }) %>
+      <%= f.text_field(:auth_uid, { :tabindex => 5 }) %>
+      <%= f.error_message_on(:auth_uid) %>
     </div>
     <span class="form-help deemphasize"><%= t 'user.new.auth no password' %></span>
   </fieldset>
       <label for='user[pass_crypt]' class="standard-label">
         <%= t 'user.new.password' %>
       </label>
-      <%= password_field(:user, :pass_crypt, { :tabindex => 6 }) %>
-      <%= error_message_on(:user, :pass_crypt) %>
+      <%= f.password_field(:pass_crypt, { :tabindex => 6 }) %>
+      <%= f.error_message_on(:pass_crypt) %>
     </div>
     <div class="form-row">
       <label class="standard-label">
         <%= t 'user.new.confirm password' %>
       </label>
-      <%= password_field(:user, :pass_crypt_confirmation, { :tabindex => 7 }) %>
-      <%= error_message_on(:user, :pass_crypt_confirmation) %>
+      <%= f.password_field(:pass_crypt_confirmation, { :tabindex => 7 }) %>
+      <%= f.error_message_on(:pass_crypt_confirmation) %>
     </div>
   </fieldset>