From: Andy Allan Date: Thu, 12 Aug 2021 16:09:07 +0000 (+0100) Subject: Use user_account_path for links to settings page X-Git-Tag: live~2026^2~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/d797de431716252ac03ad390b3233c91fa3c50b2 Use user_account_path for links to settings page Much easier to read than having to be explicit about controllers etc --- diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 7b1c52ca6..2a00a49b0 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -93,10 +93,10 @@ class ConfirmationsController < ApplicationController current_user.tokens.delete_all session[:user] = current_user.id session[:fingerprint] = current_user.fingerprint - redirect_to :controller => :users, :action => :account, :display_name => current_user.display_name + redirect_to user_account_path(current_user) elsif token flash[:error] = t "confirmations.confirm_email.failure" - redirect_to :controller => :users, :action => :account, :display_name => token.user.display_name + redirect_to user_account_path(token.user) else flash[:error] = t "confirmations.confirm_email.unknown_token" end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 727d8ee3f..e3d5173a7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -28,7 +28,7 @@ class UsersController < ApplicationController if current_user&.terms_agreed? # Already agreed to terms, so just show settings - redirect_to :action => :account, :display_name => current_user.display_name + redirect_to user_account_path(current_user) elsif current_user.nil? && session[:new_user].nil? redirect_to login_path(:referer => request.fullpath) end @@ -47,7 +47,7 @@ class UsersController < ApplicationController if params[:referer] redirect_to safe_referer(params[:referer]) else - redirect_to :action => :account, :display_name => current_user.display_name + redirect_to user_account_path(current_user) end elsif params[:decline] redirect_to t("users.terms.declined") @@ -67,7 +67,7 @@ class UsersController < ApplicationController if params[:referer] redirect_to safe_referer(params[:referer]) else - redirect_to :action => :account, :display_name => current_user.display_name + redirect_to user_account_path(current_user) end else self.current_user = session.delete(:new_user) @@ -147,7 +147,7 @@ class UsersController < ApplicationController current_user.data_public = true current_user.save flash[:notice] = t "users.go_public.flash success" - redirect_to :action => "account", :display_name => current_user.display_name + redirect_to user_account_path(current_user) end def new @@ -297,7 +297,7 @@ class UsersController < ApplicationController session[:user_errors] = current_user.errors.as_json - redirect_to :action => "account", :display_name => current_user.display_name + redirect_to user_account_path(current_user) elsif session[:new_user] session[:new_user].auth_provider = provider session[:new_user].auth_uid = uid diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 6b6271c2b..a20474b57 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -95,7 +95,7 @@ <%= number_with_delimiter(current_user.new_messages.size) %> <% end %> <%= link_to t("users.show.my profile"), user_path(current_user), :class => "dropdown-item" %> - <%= link_to t("users.show.my settings"), { :controller => "users", :action => "account", :display_name => current_user.display_name }, { :class => "dropdown-item" } %> + <%= link_to t("users.show.my settings"), user_account_path(current_user), :class => "dropdown-item" %> <%= link_to t("users.show.my_preferences"), preferences_path, :class => "dropdown-item" %> <%= yield :greeting %> diff --git a/app/views/site/edit.html.erb b/app/views/site/edit.html.erb index d991adf39..b31b09973 100644 --- a/app/views/site/edit.html.erb +++ b/app/views/site/edit.html.erb @@ -5,7 +5,7 @@

<%= t "layouts.osm_read_only" %>

<% elsif !current_user.data_public? %>

<%= t ".not_public" %>

-

<%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), :controller => "users", :action => "account", :display_name => current_user.display_name, :anchor => "public") %>

+

<%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), user_account_path(current_user, :anchor => "public")) %>

<%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %>

<% else %> <%= render :partial => preferred_editor %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 1dd84edea..61a775c51 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -25,7 +25,7 @@ <%= link_to t(".my comments"), :controller => "diary_entries", :action => "comments", :display_name => current_user.display_name %>
  • - <%= link_to t(".my settings"), :controller => "users", :action => "account", :display_name => current_user.display_name %> + <%= link_to t(".my settings"), user_account_path(current_user) %>
  • <% if current_user.blocks.exists? %>