This project is archived and is in readonly mode.
ActiveResource.find :from won't fill prefix_options on loaded resources
-
Juan
I think I found another incorrect behavior, when an AR item returned from find or find :form gets saved it looses it's prefix_options, so if you save it, and after that you want to do anything with that object the url will be malformed.
Both behaviors are in the test case attached.
-
Juan
- Assigned user set to Ryan Bigg
-
Neeraj Singh
Hi Juan,
I'm sorry but I'm unable to follow you.
As per you
Call.find(:all, :params => { account_id => 1})is generating
"http://localhost:3000/accounts/1/calls.xml"
And
Call.find(:all, :from => :available, :params => { account_id => })is generating
"http://localhost:3000/accounts//calls.xml"
So what's the issue here?
-
Juan
The generated url for the resources = Call.find :all is OK in both calls.
The problem is when using :from => :method the returned resources when you do resource.save will produce that incomplete and invalid url.
Looking at the activeresource source I found that in some cases, including the :from method the resources loaded looses the prefix_options.
This is ok:
resources = Call.find(:all, :params => { :account_id => 1})
resources[0].save => produced a valid URLThis is not ok:
resources = Call.find(:all, :from => :method, :params => { :account_id => 1})
resources[0].save => produced an invalid URL -> returned resource looses the prefix_options[:account_id] that could make up the correct URL.I hope I could clarify a little the I think incorrect behavior.
Juan.
-
Santiago Pastorino
- State changed from incomplete to open
- Tag changed from :from, activeresource to activeresource, from
- Importance changed from to Low
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
