README.md in motion-resource-0.1.0 vs README.md in motion-resource-0.1.1
- old
+ new
@@ -20,16 +20,19 @@
self.collection_url = "users"
self.member_url = "users/:id"
end
class Post < MotionResource::Base
- attr_accessor :id, :user_id, :title, :text
+ attr_accessor :id
+ attribute :user_id, :title, :text
belongs_to :user
self.collection_url = "users/:user_id/posts"
self.member_url = "users/:user_id/posts/:id"
end
+
+Only attributes declared with `attribute` are transmitted on save. I.e. attributes declared with `attr_accessor` are considered read-only with respect to the JSON API.
Now, we can access a user's posts like that:
User.find(1) do |user|
user.posts do |posts|