Hi SD Ruby, I used to live in San Diego and be part of the community: I recently relocated to LA but thought you may allow that I consult with you about an issue I am facing.
Since I asked the question on Stack Overflow, I will share the link here so we can reference to the great answer that was given there: http://goo.gl/gbXLtg Basically, the app I would like to build allows users to: 1. Create agendas. 2. Share agendas with other users. 3. Assign roles (and permissions) to users when they share an agenda with them: for instance owner, editor, viewer. 4. Decide whether they want each agenda to have zero, one or several owner(s), editor(s) or viewer(s). 5. See, on each agenda page, a list of all the users belonging to the given agenda. 6. See, on their profile, a list of the agendas that belong to them, with the associated role they have for each. After two days of thinking and research, here is what I consider doing: - Models class User < ActiveRecord::Base has_many :roles has_many :agendas, through: :roles end class Role < ActiveRecord::Base belongs_to :user belongs_to :agenda end class Agenda < ActiveRecord::Base has_many :roles has_many :users, through: :roles end - Migration class CreateRoles < ActiveRecord::Migration def change create_table :roles do |t| t.belongs_to :user, index: true t.belongs_to :agenda, index: true t.string :privilege t.timestamps end end end I believe this would let users do #1 and #2. But, would this allow to do the following: - #3 (assign roles) thanks to the Role model and its privilege column? - #4 (decide on the go which users, with which roles, can access each agenda) by adding a new line in the Role table? - #5 (display list of users for a given agenda) with @agenda.user.role.privilege.index (not sure about the syntax here)? - #6 (display list of agendas for a given user) with @user.agenda.role.privilege.index (ditto, not sure about the syntax here)? Thank you very much for your help. Thibaud -- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
