Last active
August 29, 2015 14:00
-
-
Save sheldonbaker/11058884 to your computer and use it in GitHub Desktop.
This file contains 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 Company < ActiveRecord::Base | |
has_many :users | |
end | |
class User < ActiveRecord::Base | |
belongs_to :company | |
end | |
class Thing < ActiveRecord::Base | |
belongs_to :company | |
has_many :users # Can I somehow validate that only [email protected]_id == self.company_id? | |
validate :users_belong_to_same_company # Or do I need a custom validation method? | |
def user_ids=(user_ids) | |
# Or do I need to do it here? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment