Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active March 10, 2017 00:33
Show Gist options
  • Select an option

  • Save jendiamond/b7f3adae045fe23e2034592bba72bb1c to your computer and use it in GitHub Desktop.

Select an option

Save jendiamond/b7f3adae045fe23e2034592bba72bb1c to your computer and use it in GitHub Desktop.

Tutorial | Codebase | Stylesheets

$ rails new pic-tur-esque --database=postgresql

$ rake db:create

$ rails s

Initialize local Git repo

Add GitHub remote and push

Add Heroku remote and push


Add some Gems - Bootstrap, Haml, and simple_form

Gemfile

source 'https://rubygems.org'
# ruby-2.3.0

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

+ gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
  gem 'coffee-rails', '~> 4.2'
+ gem 'haml', '~> 4.0', '>= 4.0.7'
  gem 'jbuilder', '~> 2.5'
  gem 'jquery-rails'
  gem 'pg', '~> 0.18'
  gem 'puma', '~> 3.0'
  gem 'rails', '~> 5.0.1'
  gem 'sass-rails', '~> 5.0'
+ gem 'simple_form', '~> 3.4'
  gem 'turbolinks', '~> 5'
  gem 'uglifier', '>= 1.3.0'

group :development, :test do
  gem 'byebug', platform: :mri
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

$ bundle


Add a model

$ rails g model Picture title:string description:text

$ rake db:migrate

Add a controller

$ `rails g controller Pictures

app/controllers/pictures_controller.rb

class PicsController < ApplicationController
  def index
  end
end

Add pictures/index

app/views/pictures/index.html.haml

%h1 Index Page

Add routes

config/routes.rb

Rails.application.routes.draw do
  resources :pictures
  root 'pictures#index'
end

Add ability to create post pictures

$ `rails g controller Pictures

app/controllers/pictures_controller.rb

class PicsController < ApplicationController

  def index
  end
  
  def new
  end
  
  def create
  end
  
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment