Skip to content
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

correct a single error #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

josie00
Copy link

@josie00 josie00 commented May 5, 2016

No description provided.

@ejavaguy
Copy link
Contributor

ejavaguy commented May 5, 2016

Why do you believe the code is in error?
Your change looks like it would eliminate the prototype passed in
(replacing it with {}) and cause all records to be selected instead of
those that match the prototype expressed by the hash.

On Thu, May 5, 2016 at 3:40 AM, Josie Liu [email protected] wrote:


You can view, comment on, or merge this pull request online at:

#3
Commit Summary

  • correct a single error

File Changes

Patch Links:

https://github.com/jhu-ep-coursera/fullstack-course3-module1-zips/pull/3.patch

https://github.com/jhu-ep-coursera/fullstack-course3-module1-zips/pull/3.diff


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#3

@josie00
Copy link
Author

josie00 commented May 10, 2016

Probably the "params" could be changed to "params[:prototype]", since the params also include parameters such as "limit", "offset" and "sort"

@ejavaguy
Copy link
Contributor

params also include parameters such as "limit", "offset" and "sort"

:prototype is not a URI query parameter. The prototype fields are at the
root level. The slice() call within model.all() acts as an ad-hoc
white-listing implementation (instead of "params.require" and "include")
and strips out anything that is not :city or :state.

https://github.com/jhu-ep-coursera/fullstack-course3-module1-zips/blob/master/app/models/zip.rb#L57
prototype=prototype.symbolize_keys.slice(:city, :state) if !prototype.nil?

I won't argue that this is exactly the way Rails would do it, but it does
work the way it is implemented. Rails scaffold would have scoped the "city"
and "state" below a root node of "zip". Since we are pushing most of the
pedals ourselves, we got a chance to make up a few of our own rules (before
we learn all the conventions).

On Tue, May 10, 2016 at 4:55 AM, Josie Liu [email protected] wrote:

Probably the "params" could be changed to "params[:prototype]", since the
params also include parameters such as "limit", "offset" and "sort"


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#3 (comment)

@josie00
Copy link
Author

josie00 commented May 12, 2016

Ok. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants