Open josie00 opened 8 years ago
Probably the "params" could be changed to "params[:prototype]", since the params also include parameters such as "limit", "offset" and "sort"
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 notifications@github.com 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 https://github.com/jhu-ep-coursera/fullstack-course3-module1-zips/pull/3#issuecomment-218097721
Ok. Thank you very much!
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 notifications@github.com wrote: