Fix ActiveResource nested resources not being persisted #3107

wants to merge 1 commit into


None yet
7 participants

odorcicd commented Sep 22, 2011

Any nested resources with an ActiveResource object are not persisted so actions such as destroy won't work.
This patches ActiveResource::Base#load to set any nested resources as persisted.

I was debating simply passing in true as opposed to attrs.has_key?(resource.primary_key.to_s), thoughts?

I also changed the setup fixtures keys in load_test.rb to be strings, to avoid calling stringify_keys everywhere (should be working with string keys anyways through ActiveResource).

+1, would be nice to use methods like new? and reload on nested resources

trybeee commented Nov 10, 2011

+1, #update doesn't work on nested resources, trying to #create instead.


cjolly commented Feb 1, 2012

+1 this also breaks the dom_id method which can affect dependent javascripts and css

anikkar commented Feb 24, 2012

+1 this also breaks pithy link_to helpers for named routes

Active Resource is not part of Rails core anymore, it was extracted to its own repo. Please make sure you test with the latest version - 3.2 in this case - and if the issue still persists, feel free to open a pull request there. I'm closing the issue here, thanks!

dguerri commented Jul 10, 2012

+1 could you please submit this to the active resource repo ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment