based on ruby.railstutorial.org/ruby-on-rails-tutorial-book