Skip to content

Instantly share code, notes, and snippets.

@oivoodoo
Created July 1, 2011 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oivoodoo/1058184 to your computer and use it in GitHub Desktop.
Save oivoodoo/1058184 to your computer and use it in GitHub Desktop.
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 => "test2@mail.ru", :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