Ruby 更改网页中的URL
在同一页面中从一个选项卡移动到另一个选项卡时,如何更改URL地址?我想在何处更改routes.rb或controller中的代码 routes.rb:Ruby 更改网页中的URL,ruby,ruby-on-rails-3,url,routes,Ruby,Ruby On Rails 3,Url,Routes,在同一页面中从一个选项卡移动到另一个选项卡时,如何更改URL地址?我想在何处更改routes.rb或controller中的代码 routes.rb: Rails.application.routes.draw do resources :dashboard, only: [:index] resources :profile do collection do patch 'update_profile' patch 'change_password'
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
,现在当我选择“更新配置文件”选项卡时,我需要url是localhost:3000/profile/update\u 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
class ProfileController
单击选项卡时会发生什么(按请求)?显示控制器代码。我已经添加了控制器代码,请检查一下好吗@JagdeepSinghWhat is current behavior?单击当前页面中的选项卡时,我得到了相同的url地址。即两个选项卡的localhost:3000/profile。如果我更新密码更改,url将更改,但我希望在单击选项卡时更改url