【发布时间】:2011-08-09 14:15:12
【问题描述】:
我正在创建一个用于在用户之间上传和共享文件的应用。 我有用户和文件模型,并创建了第三个 File_Sharing_Relationships 模型,其中包含一个 sharer_id、file_id 和 shared_with_id 列。我希望能够创建以下方法:
@upload.file_sharing_relationships - lists users that the file is shared with
@user.files_shared_with - lists files that are shared with the user.
@user.files_shared - lists files that the user is sharing with others
@user.share_file_with - creates a sharing relationship
是否有任何 Rails 关联,例如我可以用来建立这些关系的“多态”?
任何建议表示赞赏。谢谢。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 models