Modelling data to specify user access

Hello, this is my second Rails app, and the first one I did had simple
data mapping. This time I am building a site for a photographer, and
they want to upload photos, and create galleries that only certain
clients can log in and have access to. There will be multiple
galleries, and the access to them will vary depending on how the admin
assigns it to each client. There is also a porftolio that everyone
coming to the site can see. So I was thinking to have one master Images
table that holds all the images, and divide it out into portfolio and
galleries.

I am sitting down mapping the data right now, but I am not sure how to
handle this. How many tables to I need and how do I map them together?
So far I have these tables:

Users
*ID
*username
*password

Images
*ID
*image_name
*path_to_image
*path_to_thumbnail

Galleries
*ID
*gallery_name

and then I’m not sure about:

Gallery_Names?
User_Access?

I’d appreciate help if anyone has had experience with this before…

Jason

The most basic way I see it is

gallery
has_many :pictures
has_many :users

So you just create the gallery and add a gallery_id to the pictures
table and to the users table.

Josh

Josh C. wrote:

The most basic way I see it is

gallery
has_many :pictures
has_many :users

So you just create the gallery and add a gallery_id to the pictures
table and to the users table.

Josh

Thanks, that part makes sense. I think though it might be more
complicated? Each user can have access to more than one gallery, and
each image can be in multiple galleries. Like if the client wants to
present the same image in a different gallery taylored for each client.

On 5/10/06, Jason [email protected] wrote:

Thanks, that part makes sense. I think though it might be more
complicated? Each user can have access to more than one gallery, and
each image can be in multiple galleries. Like if the client wants to
present the same image in a different gallery taylored for each client.

Then just change the has_many to has_and_belongs_to_many then create a
gallaries_users and gallaries_pictures table.

Josh