Sorry, typo. Should be: ``` Account has_many :users, :through => :memberships
User has_many :accounts, :through => :memberships Membership belongs_to :user belongs_to :account has_one :role # agent, owner, etc. ``` -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/johnxf SO: http://stackoverflow.com/users/75170/ On Wed, Aug 10, 2011 at 18:15, John Feminella <[email protected]> wrote: > I think you can dispense with Company altogether and just have an > association class describing a User's relationship to an Account: > > ``` > Account > has_many :users, :through => :memberships > > User > belongs_to :account > > Membership > belongs_to :user > belongs_to :account > has_one :role # agent, owner, etc. > ``` > > ~ jf > -- > John Feminella > Principal Consultant, BitsBuilder > LI: http://www.linkedin.com/in/johnxf > SO: http://stackoverflow.com/users/75170/ > > > > On Wed, Aug 10, 2011 at 16:20, Leonel *.* <[email protected]> wrote: >> Thanks Fred! >> >> The reason of this setup (might need some adjusting) is that an Account >> has an attribute paying_method. So only the account_owner is the one >> that pays. >> >> The account owner can add, edit or delete Companies and Users. He's the >> administrator for that Account. >> >> The Users under the account owner's Company, are kinda like managers or >> agents. >> >> The Users under other than the account owner's company are customers. >> >> __________________________________________ >> ACCOUNT OWNER AND AGENTS >> __________________________________________ >> So let's say Tom is the account owner. >> His company is Landscaping Solutions. >> He pays the app. >> ----------------------------------------------------- >> Users under his company (agents) can open, modify and close tickets. >> Tom (user, role: account owner) >> Rick (user, role: agent) >> Pam (user, role:agent) >> ----------------------------------------------------- >> >> ___________________________________________________ >> CUSTOMERS >> ____________________________________________________ >> So Tom invites other creates companies and invites users. >> Customers can only open tickets. >> ---------------------------------------------------- >> Goliath National Bank (company) >> Barney (user, role: customer) >> Marshall (user, role: customer) >> >> Mobious Designs (company) >> Ted (user, role: customer) >> ------------------------------------------------------ >> >> -- >> 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

