Tuesday, 24 March 2015

Basic Rails App

To create a basic application in Rails with some model validation:

rails new demo
cd demo
rails generate scaffold idea name:string{50} description:text{100}
rake db:migrate
cat > app/models/idea.rb <<EOF
class Idea < ActiveRecord::Base
  validates :name, presence: true, length: { maximum: 50 }
  validates :description, length: { maximum: 100 }
end
EOF
rails s