I have worked through the code and the tutorials from Agile Web Development with Rails 5.1, by Sam Ruby and David Bryant Copeland. The Depot project has been used through all four major Rails versions (Rails 2 – 5), and it’s been interesting to watch its evolution. My comments about the major Rails 5 features are described below, and the code is at:
One exception: I did not set up the email code (Chapter 14, Task I), because it’s boring, and I don’t want to mess with setting up a dummy mail server right now.
Major Features in Rails 5
I admit I’m not comfortable with web caching concepts – I often think that optimized database queries provide a better ROI for performance purposes; Rails has a lot of nice cache features, and the tutorial provides a couple of good examples in the code. I need to look at this topic more closely.
- Action Cable
This is a new feature for Rails 5, and it’s kinda cool. Using ActionCable in the tutorial, an admin can update catalog prices in one session, and ActionCable will then transmit the changes (via web sockets) to all other active sessions (i.e. customers) in almost real time. Pretty slick.
- Atom Feeds
- Webpack and React
Have you ever clicked on a Submit button, only to have the spinner run way too long? Well, maybe the server was just really busy, but ActiveJob can put a time-consuming process in the background and give you your mouse back. You don’t always want to do this, but for things like sending out emails and files, there’s no point in keeping the user waiting, just shove the task into ActiveJob and return control to the customer.
The code uses the Devise gem to add new users and to authenticate existing users. Oddly enough, the code was missing the registerable module, so login, logout and sign up didn’t work. Routing errors and a bit of reading in the Devise docs finally pointed me to the correct solution.
Rails has always had international capabilities, but I had not really worked with it much. The locales are defined in YAML-based files that are invoked in the controllers after installing the i18n gem. The whitespace-formatted YAML files are really annoying when you have to add a lot of text – it’s easy to screw up the correct indentation, and then you get strange errors that are difficult to trace back to bad YAML syntax.
A multi-language site – done well – is really impressive, but you will need to pay for the language expertise if you want to do it right.
MiniTest, Capybara, ChromeDriver, pretty standard Rails test suite stuff. The tutorial did not include any test coverage tools, but SimpleCov would be the obvious choice. I find it interesting that the authors have not jumped on the RSpec bandwagon, but that would have been adding an extra layer of complexity for Rails rookies. For the same reasons, I’m guessing the authors worked with the standard *.erb view files with the normal HTML tagging syntax instead of opting for HAML. I’ll address the HTML to HAML conversion task in another post.
This is a good book for learning Rails, but it is not tailored for someone completely new to web development. A previous knowledge of basic HTML tags and HTTP transactions is assumed. A PHP developer, for example, would be able to make the transition to Rails with this book, but somebody new to web development would need some hands-on training with a real live human instructor beforehand.
Try It Out!
Deployment to Heroku is complete, I’ll add some commentary about that a bit later.
(Use at your own risk.) Cheers!