Using ActiveResource, Ruby on Rails, Is there a clean way to do the following:
I have house ActiveResource model and chair ActiveResource model, and both can have comments. I want to reuse the comment ActiveResource model for both.
# ActiveResource wraps HTTP POST Requests to the following
# And then parsess the responses, and then creates instances of my ActiveResource models
POST http://3rd.party.restful.api.com/admin/houses/1/comments
POST http://3rd.party.restful.api.com/admin/houses/1/chairs/3/comments
I can only think of the following:
class Comment < ActiveResource::Base
self.site = "http://3rd.party.restful.api.com"
self.prefix = "/admin/:prefix_path/"
end
And then doing the following:
comment = Comment.new(:text => "some text", :prefix_path => "houses/1/chairs/3")
Please stop me from doing this.