Created
July 8, 2011 11:24
-
-
Save elffey/1071639 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 Profile < ActiveRecord::Base | |
has_many :profiles_users, :class_name => "ProfilesUsers" | |
has_many :users, :through => :profiles_users | |
has_many :admins, | |
:through => :profiles_users, | |
:source => :user, | |
:conditions => ["profiles_users.role = ?", "admin"] | |
has_many :editors, | |
:through => :profiles_users, | |
:source => :user, | |
:conditions => ["profiles_users.role = ?", "editor"] | |
... | |
# would like to be able to do something like this: | |
@profile.create params[:profile] | |
@profile.admins << current_user | |
@profile.editors << another_user | |
# instead the role field is being left blank | |
# ideally would also like to be able to do: | |
@profile.owner = current_user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment