Hi I have a organizations table and employess table. From the employee one employee will e administering the whole organizations That means creating other staff and what ever the activities etc. My question is how can I implement the table structure and set relation for organizations and employees table I started like organizations has_many employees employee belongs_to organization But how should I represent an employee of organization who is the administrator Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Consider this example:> organizations has_many employees > employee belongs_to organizationemployee belongs_to adminstered_organization -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi> Consider this example: > >> organizations has_many employees >> employee belongs_to organization > employee belongs_to adminstered_organizationCould you please specify the model structure and relation now? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Mac wrote:> Hi >> Consider this example: >> >>> organizations has_many employees >>> employee belongs_to organization >> employee belongs_to adminstered_organization > > Could you please specify the model structure and relation now?maybe the requirement needs to be expanded a touch as it was a little unclear to me on what this ''administrator'' does. Are you modelling a business role or a system role (and/or are they the same thing?). Are there other roles you may need to model as this would potentially change the way you implement the behaviour i.e. the introduction of a roles model. PS I found that a good guide to associations which helped me was http://guides.rubyonrails.org/association_basics.html -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Jon Cox Thanks for your reply. My idea is to create a saas based application which has the initial signup procedure in basecamp like https://signup.37signals.com/basecamp/Basic/signup/new?source=signin-screen&__utma=1.193660493.1263811484.1263811484.1264389803.2&__utmb=1.10.10.1264389803&__utmc=1&__utmx=-&__utmz=1.1263811487.1.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=basecamp&__utmv=-&__utmk=101930241 So as a first step I tried to design tables organizations and employees as above and putting organization_owner_id in in organization table .Please correct me if I am wrong Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Mac wrote:> Hi Jon Cox > > Thanks for your reply. My idea is to create a saas based application > which has the initial signup procedure in basecamp like > > https://signup.37signals.com/basecamp/Basic/signup/new?source=signin-screen&__utma=1.193660493.1263811484.1263811484.1264389803.2&__utmb=1.10.10.1264389803&__utmc=1&__utmx=-&__utmz=1.1263811487.1.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=basecamp&__utmv=-&__utmk=101930241 > > > So as a first step I tried to design tables organizations and employees > as above and putting organization_owner_id in in organization table > .Please correct me if I am wrong > > Thanks > TomFor something like Basecamp you''ll end up with users having different types of role. Things like administrators, project managers, project leads, project members etc. I presume that a user could have more than one role as well? This lends itself to a structure to link your users to roles (or say employees to orangisation_roles) perhaps along the lines of: class Employee < ActiveRecord::Base has_many :employee_roles has_many :roles, :through => :employee_roles end class Role < ActiveRecord::Base has_many :employee_roles has_many :employees, :through => :employee_roles end class EmployeeRole < ActiveRecord::Base belongs_to :role belongs_to :employee end One of the roles could be the organisation owner as per your initial requirement. Again - i''d recommend reading the guide on assosiations (http://guides.rubyonrails.org/association_basics.html). more importantly though is to have a clear design to build against. I''ve recently been looking into Behaviour Driven Design (BDD) and it''s already changing the way i''m approaching my work. Work through the behaviours you need your app to deliver before you work on a solution :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.