-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
In the new resource case, we don't yet have a record available in the Pundit policies as all we've got is the class.
user_1 = User.new(id: 'user-1').save!
comment_1 = Comment.new(id: 'c-1', content: 'Is this the real life?').save!
comment_2 = Comment.new(id: 'c-2', content: 'Is this just fantasy?').save!POST /articles
{
"type": "articles",
"relationships": {
"author": {
"data": {
"type": "users",
"id": "user-1"
}
},
"comments": {
"data": [
{ "type": "comments", "id": "c-1" },
{ "type": "comments", "id": "c-2" }
]
}
}
}This will need to be addressed somehow... I'm afraid that we don't actually have any methods we could use for this case, though, as all of the relationship operation methods expect that we already have a record instance! Damn.
What should we call these methods in this case? (NOTE: The names here are arbitrary, they are just meant for a conversion starter)
ArticlePolicy#create?ArticlePolicy#create_with_user?(user_1)ArticlePolicy#create_with_comments?([comment_1, comment_2])
This discussion was splitted off from #51