Skip to content

Instantly share code, notes, and snippets.

@marklocklear
Created November 3, 2011 13:46
Show Gist options
  • Select an option

  • Save marklocklear/1336517 to your computer and use it in GitHub Desktop.

Select an option

Save marklocklear/1336517 to your computer and use it in GitHub Desktop.
#User model
class User < ActiveRecord::Base
belongs_to :organization
accepts_nested_attributes_for :organization
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :organization_attributes
end
#Org Model
class Organization < ActiveRecord::Base
has_many :users
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment