-
-
Save paulmars/960988 to your computer and use it in GitHub Desktop.
Rails, RSpec, Factory_Girl, SASS, Devise, Rails Admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rails new [appname] -JT -m https://gist.githubusercontent.com/paulmars/960988/raw/386eb14e20153ef4d55a6735d22748c6503b64f8/template.rb | |
# rails new APPNAME -JT -m /Users/paul/Development/template/template.rb | |
# sass | |
gem 'sass-rails' | |
gem 'bootstrap-sass', '3.2.0.2' | |
# image update | |
gem 'carrierwave', '0.10.0' | |
gem 'fog', '1.19.0' | |
# admin stuff | |
gem 'devise' | |
gem 'rails_admin' | |
gem 'kaminari' | |
gem_group :development, :test do | |
gem 'awesome_print' | |
gem 'quiet_assets' | |
end | |
gem_group :development do | |
gem 'binding_of_caller' | |
gem 'pry-remote', :require => 'pry-remote' | |
gem 'better_errors' | |
gem 'guard' | |
gem 'guard-livereload'#, '~> 2.4', require: false | |
gem 'guard-rspec', require: false | |
gem 'rack-livereload' | |
end | |
gem_group :test do | |
gem 'rspec-rails', '3.1.0' | |
gem 'factory_girl', '4.5.0' | |
end | |
# heroku | |
gem_group :production do | |
gem 'pg' | |
gem 'rails_12factor' | |
gem 'unicorn' | |
end | |
# ## Generators | |
insert_into_file "config/application.rb", :after => "Rails::Application\n" do | |
<<-GENERATOR | |
config.generators do |g| | |
g.stylesheets false | |
g.test_framework :rspec, :fixture => true, :views => false | |
g.fixture_replacement :factory_girl, :dir => "spec/support/factories" | |
end | |
# Global Sass Option | |
config.generators.stylesheet_engine = :sass | |
GENERATOR | |
end | |
# Run all the generators | |
generate "rspec:install" | |
# Rspec setup | |
spec_helper = <<-RSPECHELPER | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } | |
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) | |
RSpec.configure do |config| | |
config.include FactoryGirl::Syntax::Methods | |
config.use_transactional_fixtures = true | |
config.infer_base_class_for_anonymous_controllers = false | |
config.order = "random" | |
end | |
RSPECHELPER | |
remove_file "spec/spec_helper.rb" | |
create_file "spec/spec_helper.rb", spec_helper | |
generate "devise:install" | |
generate "devise:views" | |
generate "devise User" | |
## Devise routes | |
routes = <<-ROUTES | |
devise_for :user | |
devise_scope :user do | |
get "signup", :to => "devise/registrations#new" | |
get "signin", :to => "devise/sessions#new" | |
get "signout", :to => "devise/sessions#destroy" | |
end | |
ROUTES | |
route routes | |
## Sign in files | |
user = <<-USER | |
class User < ActiveRecord::Base | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable | |
attr_accessible :email, :password, :password_confirmation | |
end | |
USER | |
remove_file "app/models/user.rb" | |
create_file "app/models/user.rb", user | |
# ## Sign in files | |
# signin = <<-SIGNIN | |
# <h2>Sign in</h2> | |
# <%= semantic_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> | |
# <%= f.inputs do %> | |
# <%= f.input :email, :as => :email %> | |
# <%= f.input :password, :as => :password %> | |
# <% end %> | |
# <%= f.buttons do %> | |
# <%= f.commit_button "Sign in" %> | |
# <% end %> | |
# <% end %> | |
# <%= render :partial => "devise/links" %> | |
# SIGNIN | |
# remove_file "app/views/devise/sessions/new.html.erb" | |
# create_file "app/views/devise/sessions/new.html.erb", signin | |
# signup = <<-SIGNUP | |
# <h2>Sign up</h2> | |
# <%= semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> | |
# <%= devise_error_messages! %> | |
# <%= f.inputs do %> | |
# <%= f.input :email, :as => :email %> | |
# <%= f.input :password, :as => :password %> | |
# <% end %> | |
# <%= f.buttons do %> | |
# <%= f.commit_button "Sign up" %> | |
# <% end %> | |
# <% end %> | |
# <%= render :partial => "devise/links" %> | |
# SIGNUP | |
# remove_file "app/views/devise/registrations/new.html.erb" | |
# create_file "app/views/devise/registrations/new.html.erb", signup | |
# # Clear the default index | |
# remove_file "public/index.html" | |
# remove_file "public/images/rails.png" | |
# # Make a blank application javascript file | |
# remove_file "public/javascripts/application.js" | |
# ## Layout | |
# layout = <<-LAYOUT | |
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
# <html> | |
# <head> | |
# <title>#{app_name.humanize}</title> | |
# <%= stylesheet_link_tag "application" %> | |
# <%= csrf_meta_tag %> | |
# <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
# <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"> | |
# </head> | |
# <body> | |
# <div class="navbar navbar-fixed-top"> | |
# <div class="navbar-inner"> | |
# <div class="container"> | |
# <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> | |
# <span class="icon-bar"></span> | |
# <span class="icon-bar"></span> | |
# <span class="icon-bar"></span> | |
# </a> | |
# <%= link_to h(#{app_name.humanize}), "/", :class => "brand" %> | |
# <div class="nav-collapse collapse"> | |
# <ul class="nav pull-right"> | |
# <% if !user_signed_in? %> | |
# <li><%= link_to "Sign in", signin_path, :id => "signin-btn" %></li> | |
# <li><%= link_to "Sign up", signup_path, :id => "signup-btn" %></li> | |
# <% else %> | |
# <li><%= link_to "Sign out", signout_path, :id => "signout-btn" %></li> | |
# <% end %> | |
# </ul> | |
# </div><!--/.nav-collapse --> | |
# </div> | |
# </div> | |
# </div> | |
# <div id="body" class="container"> | |
# <% if flash.any? %> | |
# <div class="row"> | |
# <div class="span8"> | |
# <% if flash[:notice].present? %> | |
# <p class="notice"><%= notice %></p> | |
# <% end %> | |
# <% if flash[:alert].present? %> | |
# <p class="alert"><%= alert %></p> | |
# <% end %> | |
# </div> | |
# </div> | |
# <% end %> | |
# <%= yield %> | |
# </div> | |
# <%= javascript_include_tag :application %> | |
# <script type="text/javascript"> | |
# <%= yield :javascripts %> | |
# </script> | |
# </body> | |
# </html> | |
# LAYOUT | |
# remove_file "app/views/layouts/application.html.erb" | |
# create_file "app/views/layouts/application.html.erb", layout | |
# Re-Make gitignore | |
gitignore = <<-END | |
.bundle | |
.DS_Store | |
db/*.sqlite3 | |
log/*.log | |
tmp/**/* | |
END | |
remove_file ".gitignore" | |
create_file ".gitignore", gitignore | |
run "bundle install" | |
run "rake db:migrate" | |
# Git | |
git :init | |
git :add => "." | |
git commit: "-a -m 'Initial commit'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment