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 -- Posted via http://www.ruby-forum.com/.
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 On 5/10/06, Jason <jpfeifer@shaw.ca> wrote:> 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Sounds like: A Gallery has many Images A User has many Galleries A guest user could be assigned the default protfolio that everyone can see. Not sure how this looks in Rails HABTM??? but the two additional tables would be: Gallery_Images (plurals??) *gallery_id *image_id Gallery_Users *gallery_id *user_id Ross
Josh Charles 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. > > JoshThanks, 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. -- Posted via http://www.ruby-forum.com/.
On 5/10/06, Jason <jpfeifer@shaw.ca> 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