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 4060634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:21:47+00:00 2026-05-20T15:21:47+00:00

I have a model in my database whose ‘show’ action is open to viewing

  • 0

I have a model in my database whose ‘show’ action is open to viewing at URLs like:

mysite.com/project/12
mysite.com/project/14

The way my system is set up, there are a couple of defined methods through which these should be accessible:

  • A custom route I’ve set up is accessible to any visitor (registered or unregistered) who has this route. As an example, this custom route might be mysite.com/companyname/projectid, which the company might pass out itself to certain people it wants to have access. Note that this custom route runs a separate controller action, which sets some internal analytics then redirects to the show action.
  • Direct access when linked to by a registered user’s home page.

I want to restrict the ability to start with mysite.com/project/14 then simply change the IDs, thereby seeing any project. How can I do this?

Clarification

My goal with this question is not just to obfuscate record IDs to make discovering certain records harder. Instead, I would like there to be only two allowable means of accessing project/12:

  1. A user clicks on a link we provide on their home page (how can I ensure this link alone reaches project 12?)
  2. A user or simple visitor is redirected here by another (specific) controller action.

Typing in project/12 directly should not be possible. At the moment, I imagine the best way to do this would be for the two methods above to pass a code that gets picked up by the project#show action. I just don’t know how to implement this and if there are potential drawbacks.

  • 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-05-20T15:21:48+00:00Added an answer on May 20, 2026 at 3:21 pm

    Whatever you come up with – it is going to end up being security through obscurity due to this simple requirement:

    A user clicks on a link we provide on
    their home page (how can I ensure this
    link alone reaches project 12?)

    What you can do, however, is make it difficult to just straight-up guess the correct URL for the project.

    My thought would be to give every Project a unique ‘token’ – If you are not logged in as the owner of the project, then you must use the token to access it.

    For instance, in your project model you could have this:

    class Project
      before_create :set_public_token
    
      protected
        def set_public_token
          # Randomizes a 20-digit long hex code
          self.token = ActiveSupport::SecureRandom.hex(20)
        end
    end
    

    Then, in your project’s show action you would need to have this:

    class ProjectsController < ApplicationController
      def show
        @project = Project.find(params[:id])
        # Obviously you would changed signed_in? to whatever method
        # you have that verifies someone is logged in
        if !signed_in? || @project.owner_id != current_user.id
          raise "Unauthorized Access" if @project.token != params[:token]
        end
      end
    end
    

    Then the owner of the project can share the ‘public’ link of their project to people they want to have access to it, which would look something like this:

    www.example.com/projects/14?token=3jks83kasdkt84h6cd86
    

    Again, anyone with that url could access the project, and I don’t think you will be able to sanely get away from that – but it makes it a lot more difficult to do so.

    This is the same concept many password reset functions work. Anyone with access to the password reset token could reset your password after you’ve requested a password. But knowing what token to use will take you ages (Make the token longer to make it harder to bruteforce).

    That personally is how I would handle it, and how I’ve seen this sort of thing handled in the past (photobucket, private gists on github, etc)

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

Sidebar

Related Questions

I have a project that interacts with a database through ADO.net Data Services. The
Everytime I add a new Attribute to my CodeData object model I have to
It's fairly obvious how to model a database table that would act as an
I have a WCF service with an Entity Framework 4 model, using POCO classes
The Google App Engine Datastore allows each entity to have a parent entity ,
I'm currently working on a project which is using EF Code First with POCOs.
I'm currently working on a project which is using EF Code First with POCOs.
I'm working on a web app where people can save records using an industry-specific
I'm using Authlogic to manage my user sessions. I'm using the LDAP add-on, so
Short version: What's the best way to stay on the same page to run

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.