Last active
September 25, 2015 05:40
-
-
Save sepastian/8d9bf523d3950d4c8a4d to your computer and use it in GitHub Desktop.
Rails 4.2 template with active admin, devise, pundit, bootstrap, slim, unicorn, pg (optional), git
This file contains hidden or 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
# Use with `rails new -m https://gist.githubusercontent.com/sepastian/8d9bf523d3950d4c8a4d/raw/88fd29455af48f5d99569063a6239b5dcdac3d96/rails_4.2_default.rb -d postgresql` | |
require 'fileutils' | |
if Rails.version !~ /\A4\.2/ | |
puts "Required: Rails 4.2.x; found: Rails #{Rails.version}." | |
puts "$ bundle update rails" | |
exit 2 | |
end | |
# Rails 4.2 application with: | |
gem 'bootstrap-sass', '~> 3.3.3' | |
gem 'sass-rails' | |
gem 'slim-rails' | |
gem 'unicorn' | |
gem 'rails_layout' | |
gem 'activeadmin', :github => 'activeadmin' | |
gem 'pundit' | |
gem 'pg' | |
gem 'therubyracer', :platforms => :ruby | |
gem 'devise' | |
gem 'devise-i18n' | |
gem 'rails-i18n' | |
# Cleanup Gemfile, remove blank lines and comments. | |
gsub_file 'Gemfile', /gem 'sqlite3'/, '' | |
lines = File.read('Gemfile').split("\n").reject{ |l| l.strip =~ /^\s*\#/ or l.blank? } | |
remove_file 'Gemfile' | |
create_file 'Gemfile' do | |
lines.join("\n") | |
end | |
run 'bundle install' | |
## | |
# Database | |
# | |
# When using '-d postgresql', the databases APPNAME_development, APPNAME_test and APPNAME_production | |
# will be created; the users 'rails_unprivileged' and 'rails_privileged' must be created with the | |
# permission to create databases. | |
db_adapter = options['database'] | |
use_postgresql = db_adapter == 'postgresql' | |
exit if db_adapter == 'sqlite3' and no? "Are you sure you want to use #{db_adapter} as a database adapter? [nY]" | |
if db_adapter == 'postgresql' | |
db_name = app_name.underscore | |
say 'Updating config/database.yml for PostgreSQL.' | |
remove_file 'config/database.yml' | |
create_file 'config/database.yml' do <<-END.strip_heredoc | |
default: &default | |
adapter: postgresql | |
encoding: unicode | |
password: rails_unprivileged | |
username: rails_unprivileged | |
pool: 5 | |
development: | |
<<: *default | |
database: #{db_name}_development | |
test: | |
<<: *default | |
database: #{db_name}_test | |
production: | |
<<: *default | |
database: #{db_name}_production | |
username: rails_privileged | |
password: <%= ENV['#{db_name.upcase}_DATABASE_PASSWORD'] %> | |
END | |
end | |
end | |
rake('db:migrate') | |
## | |
# Bootstrap | |
generate("layout:install", "bootstrap3") | |
## | |
# Activeadmin | |
generate("active_admin:install", "AdminUser") | |
## | |
# Pundit | |
FileUtils.mkdir_p Pathname.new('app').join('policies') | |
## | |
# Git | |
after_bundle do | |
git :init | |
git :add => '.' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment