turingschool / curriculum

Turing's main repository of tutorials and projects
385 stars 502 forks source link

(id: params[:id]) instead of (params[:id] #1074

Open leoebfolsom opened 9 years ago

leoebfolsom commented 9 years ago

Hello,

I found the Slimming Controllers guide extremely useful. I only got stuck at one point: on the jumpstartlab version (linked to previously), @cached_article ||= Article.find_or_initialize_by_id(params[:id]) is recommended, while in the GitHub source code, @cached_article ||= Article.find_or_initialize_by(id: params[:id]) is recommended. In my project, only the latter worked, while the former yields a "cannot find method" error.

Thank you very much for this guide, and I hope my feedback is clear and helpful.

Leo

stevekinney commented 9 years ago

Yea, it looks like the former is a convention from Rails 3 and earlier while the latter is used in Rails 4. I'm guessing this tutorial predates Rails 4. Would you be interested in opening a pull request?