based on Rails 4 In Action book