This project is archived and is in readonly mode.
Active Resource should warn about missing prefix value
Reported by Gaston Ramos | September 13th, 2010 @ 11:43 PM | in 3.1
require 'active_resource'
class Comment < ActiveResource::Base
self.site = "http://someip.com/posts/:post_id/"
end
Comment.find(1)
#=> ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found.
This exception is not specific enough because here the first problem is that we didn't pass the :post_id param, see:
Comment.element_path(1)
# => # => /posts//comments/1.xml
and sometimes this situation could be confusing, the resource will never be found if you don't provide the prefix_params, so prefix_params should be a required param IMO.
I attached a patch that adds a new exception ActiveResource::MissingPrefixParam and works like this:
class Comment < ActiveResource::Base
self.site = "http://someip.com/posts/:post_id/"
end
Comment.find(1)
# => ActiveResource::MissingPrefixParam: post_id prefix_option is missing
Comment.element_path(1)
# => ActiveResource::MissingPrefixParam: post_id prefix_option is missing
Comments and changes to this ticket
-
Luciano G. Panaro September 14th, 2010 @ 12:51 AM
+1
Applied to both master and 3-0-stable and tests pass with patch and fail without it.
-
Rohit Arondekar September 14th, 2010 @ 04:32 AM
- State changed from new to open
- Assigned user set to Santiago Pastorino
- Importance changed from to Low
-
Lake September 16th, 2010 @ 06:17 PM
- Tag changed from activeresource, bug, edge, patch to activeresource, bug, edge, patch, verified
-
Gaston Ramos September 17th, 2010 @ 10:01 PM
- Title changed from ActiveResource::MissingPrefixParam proposal to Active Resource should warn about missing prefix value
-
Mikel Lindsaar September 27th, 2010 @ 05:03 PM
- Milestone set to 3.1
- Assigned user changed from Santiago Pastorino to Mikel Lindsaar
This is nice work. See my comments on the pull request.
-
Gaston Ramos September 27th, 2010 @ 06:11 PM
Mikel I'm sorry, I can't do a rebase against master because I removed my working copy and my local branch. I will do it right in my next patch.
-
Santiago Pastorino September 28th, 2010 @ 07:52 PM
- State changed from open to committed
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>