Created
July 1, 2011 09:45
-
-
Save oivoodoo/1058184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Account < ActiveRecord::Base | |
| has_many :memberships, :class_name => 'AccountAdministrator' | |
| has_many :administrators, :through => :memberships | |
| end | |
| class Administrator < ActiveRecord::Base | |
| has_many :memberships, :class_name => 'AccountAdministrator' | |
| has_many :accounts, :through => :memberships | |
| accepts_nested_attributes_for :memberships | |
| attr_accessible :memberships_attributes | |
| end | |
| $ a = Administrator.new(:name => "test", :email => "[email protected]", :password => "123456", :memberships_attributes => {"2"=>{"membership_role"=>"SuperAdmin", "enabled"=>"0"}, "1"=>{"membership_role"=>"Guest", "enabled"=>"1"}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment