如何验证用户是否属于他正在观看的帖子?如果不允许评论帖子,我尝试使用 if 并且我正在使用 has_many 模型关系,例如User(devise) UserPost(model) Postandcomments(belongs_to post)
我试着做<%Membership.where(user_id: self.id, group_id: group.id).any?%>
,但我得到一个错误:
PG::UndefinedColumn: ERROR: column courses.user_id does not exist
LINE 1: SELECT 1 AS one FROM "courses" WHERE "courses"."user_id" = ...
^
: SELECT 1 AS one FROM "courses" WHERE "courses"."user_id" = $1 AND "courses"."course_id" = $2 LIMIT $3