What should e relationship etween these models

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

Consider this example:

organizations has_many employees
employee belongs_to organization
employee belongs_to adminstered_organization

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?

Tom M. 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

Tom M. wrote:

Hi Jon C.

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

For 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 :slight_smile:

Hi Jon C.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs