This is a quick step-by-step guide for how I've made my latest rails app. Check the edit date to know when it was updated. Duh. ;)
It’s just easier... Who needs to mess with devops these days.
- Create an account at heroku.com
- Install the Heroku command line tools on your machine
- Install Ruby (with Rbenv?)
- Install rails (with brew? or just gem install rails?) ... I can't remember
- Install postgress
brew install postgres
- Install Virtualbox
- Install Vagrant
- Grab a Rails 5 box (e.g. jade/rails5...)
- install homebrew
- if you're having trouble accessing the network via curl you may need to configure proxies:
add the followign to your
~/.bash_profie
export https_proxy=http://your.proxy.com:80
export http_proxy=http://other.proxy.com:80
Your stuff is open source right? No? Why not?
- Visit github.com, login, and make a new repo.
- Select the Rails .gitignore template
- Return to your local machine and clone the repo into a folder there.
- Clone it locally and run
git clone [git_repo_url]
#use postgres for Heroku
rails new [git_repo_name] --database=postgresql
#create a new heroku app from here
heroku create [app_name]
Add a few gems to your Gemfile
#for GOV.UK template
gem 'govuk_template'
#gem 'slimmer'
#for other GOV.UK elements
gem 'govuk_elements_rails'
#for sass mixins
gem 'govuk_frontend_toolkit'
#slim templates
gem 'slim-rails'
#pagination
gem 'kaminari-bootstrap', '~> 3.0.1'
#bootstrap-generators
gem 'bootstrap-generators', '~> 3.3.4'
#for pretty select boxes
# use class="selectpicker"
gem 'bootstrap-select-rails'
- Add the files, commit, and push
#commit the files and the Gemfile.lock so we can deploy to heroku
git add .
git commit -am "first commit"
git push
-
Go back to heroku and open your app (maybe star it for convenient access)
-
Click “Deploy" and click the “GitHub” button
-
Connect to Github, find your repo and connect it to your app
-
Click automatic deploys if you want this.
-
Back to your code, update your
config/database.yml
like so:
default: &default
adapter: postgresql
pool: 5
encoding: unicode
timeout: 5000
development:
<<: *default
database: infoshare_dev
test: &test
<<: *default
database: infoshare_test
cucumber:
<<: *test
Make sure the database is running
#see how to start it (if you installed via brew)
brew info postgres
#Run whatever command the above recommends for your needs (e.g. run backround process or just keep it open in a shell)
#setup the databse
rake db:setup
rake db:migrate
Re-run bundler:
`bundle`
Create a Procfile
that looks like this:
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
Start herou locally
heroku local
- Write some tests, create some models, migrate your database, create some views, commit re-deploy... rinse and repeat.
Heroku won't do this for you automagically
NOT FINISHED
Add this to your Gemfile
in the :develompent section (what about :test?)
gem 'cucumber' #our testing framework
gem 'selenium-webdriver' #usual, firefox driver
gem 'phantomjs'
gem 'poltergeist' #headless driver
gem 'rspec' #gives us a few nice methods like "page.should"
gem 'pry' # for command line debugging
gem 'capybara-screenshot'
gem 'firefox'
#gem 'cucumber-rails', :require => false
# database_cleaner is not required, but highly recommended
gem 'database_cleaner'
now run cucumber --init
to set up the folders, etc.
Add these gems to your Gemfile
#for GOV.UK template
gem 'govuk_template'
#gem 'slimmer'
#for other GOV.UK elements
gem 'govuk_elements_rails'
#for sass mixins
gem 'govuk_frontend_toolkit'
You'll need to make a layouts/application.html.slim
file. See here.
- Register your app on the Google console (if that's what you're using)
- Get your client ID and secret
- use a .env file to hold these in environment variables
- Create a sessions controller with methods for new (basically redirects to the /auth URL), create (handles the callback), destroy (logs out),
- Create "signed_in?" method in
application_controller.rb
- Add this,
before_filter :check_login, :except=>[:welcome, :about]
to allow non-logged in folk to see the welcome & about pages. - Add the "check_login" method..
- Add a User model to hold name, email, is_admin? flag, etc.
- Add a user controller to perform CRUD operations on Users
##Troubleshooting
Make sure you’ve committed your secrets.yml file (check you .gitignore)