Posts Tagged ‘activeresource’

Nov 08

This happened to me today when using ActiveResource.

For example, Order.find(:all), whereby Order is an ActiveResource object, always returns the ‘cant mass-assign’ error.

The error is really not informative.

So after a couple of head-scratching hours, it turns out that if the result of Order.find(:all) includes a Shipment object, for example, then we should not have an ActiveRecord app/models/shipment.rb in our application.

It’s just a naming conflict it seems. I’m not really sure why this happens, but hopefully this helps others who may encounter the same problem.

Oct 14

Ever that kind of error when trying to use HttpMock to test your ActiveResource client code ?

I got that error, and for hours couldnt figure out why. I have followed the tests in the library (such as test/base_test.rb):

ActiveResource::HttpMock.respond_to do |mock|
mock.get “/people/1.xml”, {}, @somexml

Well, it turns out that I need to set .site = “http://localhost” on the ActiveResource class I’m using!

Hope this helps anyone who experience the same problem as mine.