更改网页中的URL

当我从一个标签移动到同一页面中的另一个标签时,我怎么能更改URL地址? 我想在routes.rb或控制器中更改代码?

routes.rb中:

Rails.application.routes.draw do resources :dashboard, only: [:index] resources :profile do collection do patch 'update_profile' patch 'change_password' end end devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' } root 'dashboard#index' end 

我当前的url是localhost:3000/profile ,现在当我选择update_profile选项卡时,我需要url为localhost:3000/profile/update_profile而不呈现新页面

控制器代码:

 class ProfileController < ApplicationController before_action :set_user, only: %i[index update_profile] def index @address = if @user.address @user.address else Address.new end end def update_profile respond_to do |format| if @user.update(user_params) format.html { redirect_to profile_index_path, notice: 'Profile was successfully updated.' } else format.html { render :index } end end end def change_password @user = current_user if @user.update_with_password(user_password_params) redirect_to root_path else render "index" end end private def set_user @user = User.find(current_user.id) end def user_params params.require(:user).permit(:name) end def address_params params.require(:user).permit(address: %i[area state country]) end def user_password_params params.require(:user).permit(:password, :password_confirmation, :current_password) end end