I made this personal cheat sheet to remind myself what to do when I start a new rails app.

1.To make a new rails app specifying the version:

rails _4.1.7_ new myapp

This creates a new Rails app with Rails version 4.1.7 with SQLite3 as the default database.

2. Modify the Gemfile. This is my basic Gemfile with the options of PostgreSQL database, Bootstrap, HAML, Sass, RSpec and Figaro.

source 'https://rubygems.org'
ruby '2.1.5'


gem 'rails', '4.1.7'
gem 'pg'
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'bootstrap-sass'
gem 'bootstrap_form'
gem 'haml-rails'
gem 'bcrypt-ruby'
gem 'figaro'


group :development do
  gem 'thin'
  gem "better_errors"
  gem "binding_of_caller"
end

group :development, :test do
  gem 'pry'
  gem 'pry-nav'
  gem 'rspec-rails', '2.99'
  gem 'fabrication'
  gem 'faker'
end

group :test do
  gem 'database_cleaner'
  gem 'shoulda-matchers', require: false
  gem 'capybara'
  gem 'capybara-email'
  gem 'launchy'
  gem 'selenium-webdriver'
  gem 'webmock'
end

group :production, :staging do
  gem 'rails_12factor'
end

3. Run bundle.

4. Edit settings for config/database.yml. Here is an example for PostgreSQL:

development:
  adapter: postgresql
  encoding: unicode
  database: myapp_development
  pool: 5
  username: postgres
  password: 

test:
  adapter: postgresql
  encoding: unicode
  database: myapp_test
  pool: 5
  username: postgres
  password: 

5. Run rake db:create.

6. If using RSpec, run rails g rspec:install.

7. Add files to gitignore:

/config/secrets.yml
/config/database.yml

8. If using Bootstrap, add to app/assets/javascripts/application.js:

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

9. Optionally, if using Bootstrap, change app/assets/stylesheets/application.css to application.css.scss and add @import "bootstrap";.

These are just the general settings I have been using to start an app.

Tags: , , ,

In categories: Rails, web development

COMMENTS

LEAVE A REPLY

Only the name field is required. Your email will not be published.