Created
March 21, 2016 10:17
-
-
Save luciuschoi/31d355531749b396c72f 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 User < ActiveRecord::Base | |
has_many :posts | |
has_many :shares | |
has_many :shared_posts, class_name: 'Post', through: :shares, source: :post | |
end | |
class Share < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :post | |
end | |
class Post < ActiveRecord::Base | |
belongs_to :user | |
has_many :shares | |
has_many :shared_users, class_name: 'User', through: :shares, source: :user | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
그리고 rake db:console 하신 후 테스트해 볼 수 있습니다.
마지막 코드라인에서 방금 전에 공유한 글을 볼 수 있게 됩니다.