Skip to content

Instantly share code, notes, and snippets.

@kheppenstall
Last active January 9, 2017 15:49
Show Gist options
  • Save kheppenstall/00725e0087b24ddfd2f616e017e3b7dd to your computer and use it in GitHub Desktop.
Save kheppenstall/00725e0087b24ddfd2f616e017e3b7dd to your computer and use it in GitHub Desktop.
New Rails Project

How to start a new project

ActiveRecord with RSpec

rails new my_project -T --database=postgresql --skip-turbolinks --skip-spring

group :development, :test do
  gem 'rspec-rails', '~> 3.5'
end

bundle install

rails generate rspec:install

Orderly

gem 'orderly'

bundle

Shoulda Matchers

group :test do
  gem 'shoulda-matchers', '~> 3.1'
end

bundle

// rails_helper.rb

Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    with.test_framework :rspec
    with.library :rails
  end
end

# Example

RSpec.describe Person, type: :model do
  it { should validate_presence_of(:name) }
end

Capybara

gem 'capybara'

bundle

// rails_helper.rb

require 'capybara/rails'

Factory Girl

# All development / test gems

group :development, :test do
  gem 'rspec-rails', '~> 3.5'
  gem 'capybara'
  gem 'factory_girl_rails'
  gem 'launchy'
  gem 'database_cleaner'
  gem 'faker
end

bundle

# Create directory and folder for factory girl:

mkdir spec/support
touch spec/support/factory_girl.rb

# Add Rspec configuration to factory_girl.rb:

RSpec.configure do |config|
  config.include FactoryGirl::Syntax::Methods
  config.before(:suite) do
    begin
      DatabaseCleaner.start
      FactoryGirl.lint
    ensure
      DatabaseCleaner.clean
    end
  end
end

# Uncomment this line from rails_helper.rb

Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

Heroku


heroku create

git push heroku master

heroku run rake db:reset

heroku open

Bootstrap

gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'

# NOTE: The sass-rails gem is included with new Rails applications by default.
# gem 'sass-rails'

bundle

# change name of application.css to application.scss and remove everything from file
// app/assets/stylesheets/application.scss

...

@import "bootstrap-sprockets"
@import "bootstrap"


// app/assets/javascripts/application.js file.

# after //= require jquery
//= require bootstrap-sprockets

## So it looks like this
// app/assets/javascripts/application.js

...

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .

Bootstrap Forms

gem bootstrap_form

bundle

// app/assets/stylesheets/application.scss
@import "rails_bootstrap_forms";
 

Styling Resources

[Color gradients] (http://uigradients.com/#)

HAML

gem "haml-rails", "~> 0.9"

https://github.com/indirect/haml-rails

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