Skip to content

Instantly share code, notes, and snippets.

@madkap
Last active August 29, 2015 14:20
Show Gist options
  • Save madkap/6ac4da8141d20c374798 to your computer and use it in GitHub Desktop.
Save madkap/6ac4da8141d20c374798 to your computer and use it in GitHub Desktop.
Oh That's How You Do That

Gems

My defaults for starting a rails app

Formtastic

gem 'formtastic'

https://github.com/justinfrench/formtastic

Slim

gem 'slim-rails'

https://github.com/slim-template/slim-rails

Jquery-Turbolinks

gem 'jquery-turbolinks'

https://github.com/kossnocorp/jquery.turbolinks

Bourbon

gem 'bower'

rails generate bower:install

https://github.com/spagalloco/bower

Sorcery

Is a gem that handles logins, authentication stuff

https://github.com/NoamB/sorcery/wiki/Simple-Password-Authentication

Friendly_id

Used for pretty URLs

gem 'friendly_id', '~> 5.0.0'

rails generate friendly_id

https://github.com/norman/friendly_id http://norman.github.io/friendly_id/

Paperclip

File management

gem "paperclip", "~> 3.0"

https://github.com/thoughtbot/paperclip

Pry-rails

Binding.pry

gem 'pry-rails', :group => :development

https://github.com/rweng/pry-rails

Bluecloth

Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

gem 'bluecloth', '>= 2.0.0'

http://epochwolf.com/blog/2010/01/18/using-bluecloth-20/ http://deveiate.org/projects/BlueCloth

JS-Routes

gem 'js-routes'

Gives all rails created routes in JS...

#Heroku

Managing Heroku Apps

Connect existing app

 heroku git:remote -a APP_NAME

This connects an already created heroku app with local repo. Default remote name of 'heroku' given.

Manage multiple environments

heroku fork -a SOURCE_APP TARGET_APP
git remote add TARGET_APP git@heroku.com:TARGET_APP.git

heroku config:set RACK_ENV=staging RAILS_ENV=staging --remote TARGET_APP

https://devcenter.heroku.com/articles/multiple-environments#starting-from-an-existing-app Connects local with another remote:name and which app to connect

Deployment

Custom Rake task

http://michaeldwan.com/writings/customize-your-heroku-deployment.html

rake deploy:production
rake deploy:staging

Databases

Seed

heroku run rake db:seed --app Remote_App_name

Migrations

heroku run rake db:migrate

heroku run rake db:migrate --app REMOTE_APP_NAME

Releases

Release History and Rollback

heroku releases

heroku rollback v30

PSQL

List all databases

\list

PG Dump

To backup databases

pg_dump dbname > outfile

#Rails Stuff

Create new Rails server

rails new #app_name#
rake db:setup

http://guides.rubyonrails.org/getting_started.html

Heroku setup

https://devcenter.heroku.com/articles/getting-started-with-rails4

Seeding DB data

To create initial data for rails site.

#seeds.rb

["windows", "linux", "mac os x"].each do |os|
  OperatingSystem.find_or_create_by_name(os)
end


Country.delete_all
open("filepath/countries.text") do |countries|
  countries.read.each_line do |country|
    code, name = country.chomp.split("|")
    Country.create!(name: name, code: code)
  end
end

http://railscasts.com/episodes/179-seed-data

Setting up POW

http://pow.cx/

ZEUS

https://github.com/burke/zeus

gem install zeus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment