Open abuiles opened 8 years ago
I'd like to get the code fixed instead of adding a note to the README.
@lgebhardt sounds great, I wanted to confirm if it was intended behavior or a bug.
Are you thinking about a flag in the relationship to mark it as immutable? There could be scenarios where you might want to protect only some of the relationships.
class MotorcycleResource < JSONAPI::Resource
attributes
has_many :likers # you can modify this
belongs_to :brand, immutable: true # but the brand should be read only
end
@abuiles I think I misunderstood the question. In your first example I was assuming you were making the brand
immutable
, which I now see is probably not the case. If the resource is immutable
it should restrict the modification of the relationships by not generating the routes. I assumed you were reporting that this wasn't happening, hence the bug label.
To clarify are you just looking making relationships immutable? If so this should be a new feature, not a bug.
To clarify are you just looking making relationships immutable? If so this should be a new feature, not a bug.
Correct, making brand
immutable works as expected - only GET
is defined for that resource, but I want to mark some relationships as immutable too. That's why I did the workaround through the routes.
@abuiles Ok, let's plan to add the immutable flag to relationships as well as resources.
Whats the status on this issue? I would very much like to use it.
From the docs, it looks like we can make a resource read-only by using
immutable
, but, is there a similar option to restrict operations in a relationship?Given the following
I want to restrict the operations between
brands/relationships/motorcycles
so onlyGET
is allowed.I found a workaround doing the following, but I wonder if there is a better solution.
If that's the case I'll gladly add a note to the README so others can find it too.
Thanks!