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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:01:05+00:00 2026-05-17T20:01:05+00:00

looking to see if there are some ideas on how I should introduce the

  • 0

looking to see if there are some ideas on how I should introduce the idea of a logged-in “user” that effectively ‘federates’ the data….let me explain.

I have been building my app so far as if there is only one user. Me. All the data and reports are specific to me. I just added authlogic.

I now want to be able to introduce a way for a new user to log in, not see any of my data, and use the application. And eventually to pay to use the system.

So far, my assumption is I’d have to go into the models and add a user_id to pretty much each of them, and then go to all controllers and have them search by user.

But I am wondering if there are gems, suggestions, ideas of a better way to federate the data for each user.

Oh…I may want to enable more than one user to have access to some or all of the data belonging to another user. This is for small teams of sales people that may want to share.

So…ideas before I try fumbling around myself…thank you 🙂

  • 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-17T20:01:05+00:00Added an answer on May 17, 2026 at 8:01 pm

    You’ve got the right idea. You have to make relationships between users and the data models. In some cases, it might be a simple belongs_to :user, but if you want multiple users to access certain data, it’s going to have to be a many-to-many relationship has_and_belongs_to_many :users.

    Then, we simply change the way we fetch data:

    # Some controller, no restrictions
    def index
      @reports = Report.all
    end
    
    def view
      @report = Report.find(params[:id])
    end
    
    # Some controller, with restrictuons
    def index
      @reports = current_user.reports.all
    end
    
    def view
      @report = current_user.reports.find(params[:id])
    end
    

    Using the above logic, users will only see whatever data they have a relationship to.

    It’s probably going to be a little bit of work if you’ve already created most of the application, no doubt. What you have to be really, really, really careful with is not leaving any Report.all or Report.find(params[:id]) lying around, as that can lead to vulnerabilities–users would be able to access data that isn’t actually theirs.

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

Sidebar

Related Questions

I am looking to see if there is an open source/free project that provides
Looking at some code I'm maintaining in System Verilog I see some signals that
Looking to see if there's an existing method or application to increase display size
I'm looking to see if there is any way of getting around type erasure
Hello I am looking to see if there are any modules for drupal 6
Hi I'm looking but can't see Is there a way to change the caption
I'm looking to see if I can design a HtmlHelper extension method that will
There are tons of things wrong with this page, but I'm looking for some
Theoretically, the end user should never see internal errors. But in practice, theory and
Looking to see what others do with 3rd party (vendor) java documents? Do they

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.