Fork me on GitHub

Project Notes

Ruby on Rails 4

Features and demonstration of Rails 4.


Key Features of Rails 4

  • Ruby 2.0 preferred; 1.9.3+ required
  • Strong Parameters
  • Turbolinks
  • Russian Doll Caching

Checking Pre-requisites and Installation

$ ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-darwin17]
$ sqlite3 --version
3.19.3 2017-06-27 16:48:08 2b0954060fe10d6de6d479287dd88890f1bef6cc1beca11bc6cdb79f72e2377b
$ gem install rails -v 4.2.11
$ rails --version
Rails 4.2.11


Creating a Simple App

$ rails new minime4
$ cd minime4
$ rake db:migrate
$ rails server
=> Booting WEBrick
=> Rails 4.2.11 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2019-02-26 11:35:32] INFO  WEBrick 1.3.1
[2019-02-26 11:35:32] INFO  ruby 2.4.3 (2017-12-14) [x86_64-darwin17]
[2019-02-26 11:35:32] INFO  WEBrick::HTTPServer#start: pid=65375 port=3000

Gem::LoadError: can’t activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile.

Update Gemfile to pin gem 'sqlite3', '~> 1.3.6' and re-run bundle

Hit http://localhost:3000..


Adding a Welcome Page

Using controller generator:

rails generate controller Welcome index

Adjust routes to use this as the main page.



$ rake test
Running via Spring preloader in process 65406
Run options: --seed 60891

# Running:


Finished in 0.340621s, 2.9358 runs/s, 2.9358 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

Adding The Blog App

The getting started guide has always outlined a simple blog application. Adding the basic features to minime5:

rails generate controller Articles
rails generate model Article title:string text:text
rake db:migrate

Credits and References

About LCK#47 rubyrails
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.