Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:43:15+00:00 2026-06-10T20:43:15+00:00

I would like to hide or mask example.com/users/$ID/edit to be example.com/profile/edit . config/routes.rb resources

  • 0

I would like to hide or mask example.com/users/$ID/edit to be example.com/profile/edit.

config/routes.rb

resources :users

app/controllers/users_controller.rb

def edit
@user = User.find(params[:id])
end

I’ve tried adding the route

match '/profile/edit' => 'users#edit', :as => :edit_profile

but, when I visit example.com/profile/edit, the edit method complains about not being able to find the user’s ID.

Is there a way I can mask the ID from the browser?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:43:17+00:00Added an answer on June 10, 2026 at 8:43 pm

    If you’re trying to edit the current user’s profile you could use the following in your edit action:

    
        def edit
          @user = User.find_by_id( params[:id] ) || current_user
        end
    

    This will first try to look up the user by the id parameter returning nil if it can’t find the user and if the return value is nil it will set @user to the return value of the current_user helper method. This assumes you’re using something like Devise which provides the current_user method to get the currently logged in user.

    One other note. You should change match in your route to get to specify that only get requests are valid for the edit action.

    
    
        get 'profile/edit' => 'users#edit' , as: edit_profile
    
    

    If you’re trying to prevent users from editing other people’s profiles you need something like the following after you load the user:

    
    
        redirect_to( root_path ) and return unless @user == current_user
    
    

    This will keep the current user from editing another user’s profile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to hide the user_id in the URL if I can. http://domain.com:3000/users/1
I have an ipad app where i would like to hide and show a
I have been developing an Android app. I would like to hide the OK
I'm working on a rails app and would like to hide away some code
I have a Rails app that uses activescaffold and I would like to hide
I would like to hide any text matching a pattern from any HTML page,
I would like to hide all class=csc-content where previous sibling is a h4 class=faq.
I would like to hide dive after the animation. Is it possible ? I
In the following code I would like to hide Hello world but keep visible
I have an UserControl and would like to hide the resizing handles in design-time,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.