-
Notifications
You must be signed in to change notification settings - Fork 360
adding shortcut: find(x) = find(:one, :from => x) when x is a url #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
x can be a full url
I would really appreciate any feedback on this. This is a very early part of an idea to decouple URL generation from ActiveResource. It seems more 'RESTful' to store the URL of a resource rather than an arbitrary ID. Eventually I think it would be useful to use a finder like this when dealing with associations as well. For example:
Calling p.comments could use Comments.find(p.comments_url), rather than being generated by ActiveResource. A better example is probably pagination. Github uses the Link header for their pagination. It would be great to see ActiveResource eventually support something like this.
This probably introduces some problems with parsing paginated results and index actions as well, but it would make ActiveResource a lot more useful for my needs. thanks |
I like this direction, too: working with URLs and Link headers. Navigating an API. |
I like the idea, too. +1 from me. |
Some more feedback or just merge? |
@SweeD thanks for mention. 👍 from my side. |
The implementation feels bolted on. I think working with URIs natively needs deeper consideration. Parsing every id as a URI will be surprising in many cases, too: |
I agree that it feels bolted on. Currently the find method works the way it did in ActiveRecord, using the first param to find out what sort of search it should be doing. Is there a better way do find overall? |
Checking for a |
I would love GitHubRepos.find(params[:id], :site => "https://api.github.com/repos") |
There is already a option for that: GitHubRepos.find(params[:id], from: "https://api.github.com/repos") Or did you mean especially the |
@jeremy said:
Sounds like a goog idea to me. What do you guys think? |
@SweeD right, I mean the |
@sfaxon thoughts on checking |
@sfaxon What do you think about jeremy's idea? |
@sfaxon Anything new here? 😏 |
I think the find method should work given a URI, but I think it would also result in some bulky method calls like this:
Which can be easily fixed with a helper method that takes a string, converts to a URI and then calls find. I'm glad people like the general direction, that's all the feedback I was trying to get. Actually implementing this should probably touch a lot more places to make sure it's consistent, so I'll close the pull request. Thanks for the feedback! |
No description provided.