Forum: Ruby on Rails Only allowing areas of site to users using authentication

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Guest (Guest)
on 2006-03-14 16:40
I have a site in development where I only want specific users to access
specific items that uses belongs_to and has_many.

Say we have this kind of structure.

Person <belongs_to + has_many> Items

When person logged in they only have access to items that belongs to

I'm using auth_generator but only seem to put an auth inside controllers
and dont know how to go any futher.

Any help would be great.
Guest (Guest)
on 2006-03-14 16:49
To further ellaborate...

This is my table structure

Client (has many domains)
Domain (belongs to client and has many reports)
Report (belongs to domain)

Currently when I select client in the frontend it shows me what domains
belong to that client. I want to set up that when a client logs in it
shows the domains/reports that belong to them.

Jan P. (Guest)
on 2006-03-14 17:45
(Received via mailing list)
Hi, Guest,

I think your problem isn't solely about authentication. IMHO you simply
the following steps:

#1: Check if there is a user authenticated => if not display the login
or a guest page or whatever
#2: Read the session to get the user who is authenticated => don't know
to do this with auth_generator but probably it's something like
#3: use the relation from the read out user with something like:
#4: Display the resulting items

Best Regards
Jan P.
This topic is locked and can not be replied to.