Skip to content

Instantly share code, notes, and snippets.

@QuintinAdam
Last active December 27, 2015 03:29
Show Gist options
  • Save QuintinAdam/7259794 to your computer and use it in GitHub Desktop.
Save QuintinAdam/7259794 to your computer and use it in GitHub Desktop.
Basic Rails Set Ups

Some of the basic setup for the gems I use the most.

source 'https://rubygems.org'

  gem 'rails', '3.2.15' 
  gem 'simple_form'
  gem 'devise'
  gem 'figaro'
  gem 'font-awesome-sass-rails'
  gem "paperclip", "~> 3.0"

  gem 'pg'

  group :development, :test do
    gem 'powder'
    gem 'better_errors'
    gem 'binding_of_caller'
    gem 'meta_request'
    gem 'xray-rails'
    gem 'guard'
    gem 'rb-fsevent', require: false
    gem 'guard-pow'
    gem 'guard-minitest'
    gem 'guard-livereload'
    gem 'rack-livereload'
    gem 'ruby_gntp'
    gem 'pry-rails'  
    gem 'factory_girl_rails', '>= 4.2.0'
    gem 'ffaker'
    gem "email_spec"
    gem 'coveralls', require: false
    gem "letter_opener"
    gem "minitest-rails", github: 'blowmage/minitest-rails'
    gem 'minitest-matchers'
    gem 'minitest-rails-capybara'
    gem 'minitest-colorize'
    # gem 'minitest-focus'
    # gem "database_cleaner", ">= 1.0.0.RC1"
  end

  group :production do
    
  end
  
  group :assets do
    gem 'sass-rails',   '~> 3.2.3'
    gem 'coffee-rails', '~> 3.2.1'
    gem 'uglifier', '>= 1.0.3'
    gem "bootstrap-sass", github: "thomas-mcdonald/bootstrap-sass"
  end
  
  gem 'jquery-rails'

+++++++++++++++++ *Simple form +++++++++++++++++ https://github.com/plataformatec/simple_form

rails generate simple_form:install rails generate simple_form:install --bootstrap

Be sure to have a copy of the Bootstrap stylesheet available on your application, you can get it on http://twitter.github.com/bootstrap.

Inside your views, use the 'simple_form_for' with one of the Bootstrap form classes, '.form-horizontal', '.form-inline', '.form-search' or '.form-vertical', as the following:

= simple_form_for(@user, :html => {:class => 'form-horizontal' }) do |form|

Usage = <%= simple_form_for @user do |f| %> <%= f.input :username %> <%= f.input :password %> <%= f.button :submit %> <% end %>

+++++++++++++++++ Devise +++++++++++++++++ https://github.com/plataformatec/devise

rails generate devise:install in config/environments/development.rb:

   config.action_mailer.default_url_options = { :host => 'localhost:3000' }

  Ensure you have defined root_url to *something* in your config/routes.rb.
  For example:

   root :to => "home#index"
   
  Ensure you have flash messages in app/views/layouts/application.html.erb.
  For example:

   <p class="notice"><%= notice %></p>
   <p class="alert"><%= alert %></p>
   
  If you are deploying on Heroku with Rails 3.2 only, you may want to set:

   config.assets.initialize_on_precompile = false
   
  On config/application.rb forcing your application to not access the DB
  or load models when precompiling your assets.   
 
  You can copy Devise views (for customization) to your app by running:

   rails g devise:views

The generator will install an initializer which describes ALL Devise's configuration options and you MUST take a look at it. Change: config.mailer_sender When you are done, you are ready to add Devise to any of your models using the generator:

rails generate devise User/Admin

+++++++++++++++++ Figaro +++++++++++++++++ https://github.com/laserlemon/figaro

rails generate figaro:install

Add secret_token, devise_secert, Mail_default, mail_pass

rake figaro:heroku

+++++++++++++++++ font-awesome-sass-rails +++++++++++++++++

@import 'font-awesome';

+++++++++++++++++ paperclip +++++++++++++++++

+++++++++++++++++ Guard +++++++++++++++++

guard init pow guard init minitest guard init livereload

Make sure it looks like this:

guard 'livereload' do
  watch(%r{app/views/.+\.(erb|haml|slim)$})
  watch(%r{app/helpers/.+\.rb})
  watch(%r{public/.+\.(css|js|html)})
  watch(%r{config/locales/.+\.yml})
  # Rails Assets Pipeline
  watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
end

guard 'minitest' do
  # with Minitest::Unit
  watch(%r|^test/(.*)\/?(.*)\_test.rb|)
  watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "test/#{m[1]}#{m[2]}_test.rb" }
  watch(%r|^test/test_helper\.rb|)    { "test" }
  watch(%r{test/factories/.+\.rb})

  # with Minitest::Spec
  # watch(%r|^spec/(.*)_spec\.rb|)
  # watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  # watch(%r|^spec/spec_helper\.rb|)    { "spec" }

  # Rails 3.2
  watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/controllers/#{m[1]}_test.rb" }
  watch(%r|^app/helpers/(.*)\.rb|)     { |m| "test/helpers/#{m[1]}_test.rb" }
  watch(%r|^app/models/(.*)\.rb|)      { |m| "test/models/#{m[1]}_test.rb" }

end

guard 'pow' do
  watch('.powrc')
  watch('.powenv')
  watch('.rvmrc')
  watch('.ruby-version')
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('config/application.rb')
  watch('config/environment.rb')
  watch(%r{^config/environments/.*\.rb$})
  watch(%r{^config/initializers/.*\.rb$})
end

+++++++++++++++++ Letter_opener +++++++++++++++++ https://github.com/ryanb/letter_opener

Then set the delivery method in config/environments/development.rb

config.action_mailer.delivery_method = :letter_opener

+++++++++++++++++ Minitest-rails +++++++++++++++++ https://github.com/blowmage/minitest-rails

rails generate mini_test:install

+++++++++++++++++ Bootstrap-scss-rails +++++++++++++++++ https://github.com/thomas-mcdonald/bootstrap-sass

@import 'bootstrap_and_overrides';

@import "bootstrap";

//= require bootstrap

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