The Rails 4 Way (2014)
Ruby Toolbox
Didn’t see what you’re looking for in the list above?
https://www.ruby-toolbox.com
This site lists and organizes a lot of Ruby and Rails gems by category and popularity. It’s usually the first place to look if you’re searching for 3rd-party functionality to add to your Rails application.
Screencasts
Screencasts are videos distributed online that teach you a narrowly focused topic of interest by capturing actual screen output (hence the name) while the author explains concepts and writes code. The Rails community loves to create screencasts!
Railcasts
http://railscasts.com/
Short on cash? Host Ryan Bates posts a new screencast almost every two weeks for free. Episodes range between 5 to 15 minutes in length and are focused on Rails specific topics.
1. rbenv allows you to easily install, manage and work with multiple Ruby versions and it’s a must-have tool for modern Rails developers. https://github.com/sstephenson/rbenv↩
2. http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/↩
3. Comically, the Rails inflection of virus is also wrong. See http://en.wikipedia.org/wiki/Plural_form_of_words_ending_in_-us#Virus↩
4. https://github.com/rails/spring↩
5. Practically every PHP application ever written has this problem.↩
6. Full comments at http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up↩
7. Examples drawn from Yehuda Katz’ excellent blog post about generic↩
8. For those interested in REST, the canonical text is Roy Fielding’s dissertation, which you can find at http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm. In particular, you’ll probably want to focus on Chapters 5 and 6 of the dissertation, which cover REST and its relation to HTTP. You’ll also find an enormous amount of information, and links to more, on the REST wiki at http://rest.blueoxen.net/cgi-bin/wiki.pl.↩
9. Yehuda has written an excellent description of how to register additional rendering options at https://blog.engineyard.com/2010/render-options-in-rails-3/↩
10.For more information on JSON go to http://www.json.org/.↩
11.MIME is specified in five RFC documents, so it is much more convenient to point you to a rather good description of MIME provided by Wikipedia at http://en.wikipedia.org/wiki/MIME.↩
12.For a full list of HTTP status codes, consult the spec at http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.↩
13.Puma Web Server http://puma.io/↩
14.More information, particularly about webserver configuration available at http://rack.rubyforge.org/doc/Rack/Sendfile.html↩
15.See the official spec at http://www.w3.org/Protocols/rfc2616/rfc2615-sec14.html.↩
16.Heiko Webers has an old, yet still useful write-up about sanitizing filenames at http://www.rorsecurity.info/2007/03/27/working-with-files-in-rails/.↩
17.Sanitization prevents SQL injection attacks. For more information about SQL injection and Rails see http://guides.rubyonrails.org/security.html#sql-injection.↩
18.https://github.com/rails/arel/↩
19.Check out the excellent http://rubular.com if you need help composing Ruby regular expressions.↩
20.If you need to validate email addresses try the plugin at https://github.com/spectator/validates_email↩
21.http://lesscode.org/2006/03/12/someone-tell-gosling/↩
22.If you are browsing old Rails source code, you might come across callback macros receiving a short string of Ruby code to be eval’d in the binding of the model object. That way of adding callbacks was deprecated in Rails 1.2, because you’re always better off using a block in those situations.↩
23.I recommend the excellent Geocoder gem available at http://www.rubygeocoder.com/.↩
24.Real-life implementation of the example would also need to modify all finders to include deleted_at is NULL conditions; otherwise, the records marked deleted would continue to show up in the application. That’s not a trivial undertaking, and luckily you don’t need to do it yourself. There’s a Rails plugin named destroyed_at created by Dockyard that does exactly that, and you can find it at https://github.com/dockyard/destroyed_at.↩
25.Get Paperclip at https://github.com/thoughtbot/paperclip.↩
26.http://en.wikipedia.org/wiki/Open/closed_principle has a good summary.↩
27.For autogenerated schema information added to the top of your model classes, try the annotate gem at https://github.com/ctran/annotate_models↩
28.http://m.onkey.org/namespaced-models↩
29.http://techspot.zzzeek.org/2007/05/29/polymorphic-associations-with-sqlalchemy/↩
30.https://github.com/pluginaweek/state_machine↩
31.I don’t expect this to make sense to you, unless you are familiar with Ruby’s singleton classes, and the ability to evaluate arbitrary strings of Ruby code at runtime. A good place to start is http://yehudakatz.com/2009/11/15/metaprogramming-in-ruby-its-all-about-the-self/.↩
32.The qualifier internal is used to differentiate a domain-specific language hosted entirely inside of a general-purpose language, such as Ruby, from one that is completely custom and requires its own parser implementation.↩
33.Googling BNL will give you tons of links to the Toronto-based band Barenaked Ladies, so you’re better off going directly to the source at http://blog.jayfields.com/2006/07/business-natural-language-material.html.↩
34.http://www.domaindrivendesign.org/↩
35.https://github.com/RubyMoney/money↩
36.http://www.postgresql.org/docs/9.3/static/hstore.html↩
37.http://www.postgresql.org/docs/9.3/static/rangetypes.html↩
38.http://haml-lang.com/↩
39.http://www.decentexposure.info/↩
40.See http://www.die.net/musings/page_load_time/ for background information.↩
41.https://github.com/plataformatec/simple_form↩
42.https://github.com/justinfrench/formtastic↩
43.https://github.com/carrierwaveuploader/carrierwave↩
44.https://github.com/rails/rails/tree/4-0-stable/actionpack/lib/action_view/renderer↩
45.You can examine the source code of the html-scanner yourself by opening up https://github.com/rails/rails/blob/4-0-stable/actionpack/lib/action_view/vendor/html-scanner/html/sanitizer.rb↩
46.This section is an authorized remix of the complete guide to↩
47.The translations load path is just an array of paths to your translation files that will be loaded automatically and available in your application. You can pick whatever directory and translation file naming scheme makes sense for you.↩
48.Every string inside Rails is internationalized in this way, see for instance Active Record validation messages in the file or time and date formats in the file.↩
49.https://groups.google.com/forum/?hl=en#!topic/rails-i18n/FN7eLH2-lHA↩
50.https://github.com/svenfuchs/globalize3↩
51.https://github.com/svenfuchs/routing-filter↩
52.http://www.w3.org/International/questions/qa-lang-priorities↩
53.https://github.com/iain/http_accept_language↩
54.https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb↩
55.http://dev.maxmind.com/geoip/legacy/geolite/↩
56.https://github.com/svenfuchs/rails-i18n↩
57.http://www.unicode.org/cldr/charts/supplemental/language_plural_rules.html↩
58.https://github.com/rails/rails/blob/4-0-stable/actionpack/lib/action_view/locale/en.yml#L4↩
59.https://github.com/rails/rails/blob/4-0-stable/activesupport/lib/active_support/locale/en.yml#L155↩
60.https://github.com/rails/rails/blob/4-0-stable/activesupport/lib/active_support/locale/en.yml#L18↩
61.https://github.com/rails/rails/blob/4-0-stable/actionpack/lib/action_view/locale/en.yml#L39↩
62.https://github.com/rails/rails/blob/4-0-stable/activesupport/lib/active_support/locale/en.yml#L37↩
63.https://github.com/rails/rails/blob/4-0-stable/activerecord/lib/active_record/locale/en.yml#L37↩
64.If you want to know why it doesn’t work, you’ll have to buy the first book in this series: The Ruby Way ISBN: 0672328844↩
65.If you’re familiar with Ruby already, you might know that Proc.new is an alternate way to create anonymous blocks of code. I prefer lambda, at least in Ruby 1.9, because of subtle behavior differences. Lambda blocks check the arity of the argument list passed to them when call is invoked, and explicitly calling return in a lambda block works correctly.↩
66.http://david.heinemeierhansson.com/arc/2006_09.html↩
67.http://haml.info↩
68.http://survey.hamptoncatlin.com/survey/stats↩
69.http://haml.info/docs/yardoc/file.REFERENCE.html#doctype_↩
70.http://chriseppstein.github.io/blog/2010/02/08/haml-sucks-for-content↩
71.If you are really new to web programming and want a very thorough explanation of how web-based session management works, you may want to read the information available at http://www.technicalinfo.net/papers/WebBasedSessionManagement.html.↩
72.https://github.com/mperham/dalli↩
73.If you want to read the whole thread (all 83 messages of it), simply search Google for “Replay attacks with cookie session.” The results should include a link to the topic on the Ruby on Rails: Core Google Group.↩
74.https://github.com/plataformatec/devise↩
75.A BCrypt password is based on the Blowfish cipher, incorporating a salt and is resistant to brute-force attacks. For more information, see the Wikipedia article on the subject.↩
76.http://en.wikipedia.org/wiki/Authorization↩
77.https://github.com/elabs/pundit↩
78.http://thunderboltlabs.com/blog/2013/03/27/testing-pundit-policies-with-rspec↩
79.http://www.kalzumeus.com/2013/01/31/what-the-rails-security-issue-means-for-your-startup/↩
80.CarnegieMellon’s Software Engineering Institute says that MD5 “should be considered cryptographically broken and unsuitable for further use” http://www.kb.cert.org/vuls/id/836068↩
81.<http://tools.ietf.org/html/draft-hodges-strict-transport-sec-02?↩
82.https://github.com/mikel/mail↩
83.If you are using a third-party email service, such as SendGrid, be sure to checkout the Griddler gem by thoughtbot. It’s a Rails engine that hands off preprocessed email objects to a class solely responsible for processing the incoming email.↩
84.Carrierwave, created by Jonas Nicklas, can be found at https://github.com/jnicklas/carrierwave↩
85.Rob Orsini, author of O’reilly’s Rails Cookbook recommends getmail, which you can get from http://pyropus.ca/software/getmail.↩
86.https://github.com/bmabey/email-spec↩
87.http://www.appneta.com/blog/russian-doll-caching/↩
88.http://www.rubytutorial.io/page-caching-with-rails-4↩
89.It’s also possible to do the same with Redis. See http://antirez.com/post/redis-as-LRU-cache.html↩
90.https://github.com/rails/cache_digests#implicit-dependencies↩
91.https://github.com/rails/cache_digests#explicit-dependencies↩
92.http://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works↩
93.http://blog.remarkablelabs.com/2012/12/russian-doll-caching-cache-digests-rails-4-countdown-to-2013↩
94.http://www.regexprn.com/2011/06/web-application-caching-strategies_05.html↩
95.https://github.com/voxdolo/decent_exposure↩
96.See http://edgeguides.rubyonrails.org/caching_with_rails.html#cache-stores for a full list of support cache providers, including Terracotta’s Ehcache.↩
97.See http://http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 for more information.↩
98.Tim Bray wrote a now-classic blog post on the topic at http://www.tbray.org/ongoing/When/200x/2008/08/14/Rails-ETags↩
99.http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19↩
100. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.3.4↩
101. https://github.com/collectiveidea/delayed_job↩
102. http://sidekiq.org/↩
103. https://github.com/mperham/sidekiq/blob/master/README.md↩
104. https://github.com/resque/resque↩
105. Be careful to escape any characters that have specific meaning to your shell.↩
106. The first step to getting the Firebug plugin for Firefox is to visit http://www.getfirebug.com↩
107. http://developers.google.com/chrome-developer-tools/↩
108. https://github.com/kossnocorp/jquery.turbolinks↩
109. http://net.tutsplus.com/tutorials/ruby/digging-into-rails-4↩
110. http://en.wikipedia.org/wiki/Ajax_(programming)↩
111. We are ignoring post-processing for a moment.↩
112. For an up-to-date list of supported formats please refer to Tilt’s README file. https://github.com/rtomayko/tilt↩
113. http://tools.ietf.org/html/rfc2397↩
114. http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation↩
115. https://github.com/jnicklas/capybara↩
116. Confused about the difference between mocks and stubs?↩
117. ActiveRecord scopes are notoriously prone to causing this problem.↩
118. Pointy-Haired Boss, as per Dilbert comic strips.↩
119. Well that’s not quite true. Active Record still connects to the database to get the column information for Schedule. However, you could stub that information out as well to remove your dependency on the database completely.↩
120. http://www.extremeprogramming.org/rules/functionaltests.html↩
121. http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions↩
122. https://github.com/guard/guard-rspec↩
123. https://github.com/rails/spring↩
124. https://github.com/sandro/specjour↩
125. https://github.com/colszowka/simplecov↩
126. http://pryrepl.org↩
127. https://github.com/nixme/pry-debugger↩
128. https://github.com/ConradIrwin/pry-rescue↩