Last active
June 24, 2016 03:31
-
-
Save shun115/b028d62ecb9cd7861b5b to your computer and use it in GitHub Desktop.
new rails project
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
$ cd path/to/project | |
$ rbenv local 2.3.0 | |
$ bundle init | |
$ vi Gemfile | |
$ cat Gemfile | |
source "https://rubygems.org" | |
gem "rails" | |
$ bundle install --path vendor/bundle | |
$ be rails new . -T -d mysql --skip-turbolinks | |
$ be spring binstub --all | |
$ vi .gitignore | |
# Ignore bundler config. | |
/.bundle | |
# Ignore all logfiles and tempfiles. | |
/log/* | |
!/log/.keep | |
/tmp | |
#rails specific | |
.sass-cache/ | |
/public/system | |
/public/assets | |
/public/uploads | |
# generic files to ignore | |
*~ | |
*.DS_Store | |
*.swp | |
.rvmrc | |
.ruby-version | |
/.idea | |
/.codeintel | |
/vendor/bundle | |
.capistrano/ | |
$ vi Gemfile | |
group :deployment do | |
gem 'capistrano', require: false | |
gem 'capistrano-rails', require: false | |
gem 'capistrano-rvm', require: false | |
gem 'capistrano-bundler', require: false | |
end | |
group :test do | |
gem 'faker' | |
gem 'factory_girl_rails' | |
gem 'rb-fsevent' | |
gem 'accept_values_for' | |
gem 'terminal-notifier' | |
gem 'terminal-notifier-guard' | |
gem 'database_rewinder' | |
end | |
group :development, :test do | |
gem 'thin' | |
gem 'rspec-rails', '~> 3.0' | |
gem 'guard-rspec', require: false | |
gem 'spring-commands-rspec' | |
gem 'quiet_assets' | |
gem 'hirb' | |
gem 'hirb-unicode' | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'bullet' | |
gem 'annotate', '>=2.6.0' | |
gem 'guard' | |
end | |
gem 'settingslogic' | |
$ bundle | |
$ railss g rspec:install | |
$ be guard init | |
# databese.yml | |
encoding: utf8 | |
charset: utf8 | |
collation: utf8_general_ci | |
# utf8mb4 + ar_innodb_raw_format | |
encoding: utf8mb4 | |
charset: utf8mb4 | |
collation: utf8mb4_general_ci | |
ActiveSupport.on_load :active_record do | |
module ActiveRecord::ConnectionAdapters | |
class AbstractMysqlAdapter | |
def create_table_with_innodb_row_format(table_name, options = {}) | |
table_options = options.reverse_merge(:options => 'ENGINE=InnoDB ROW_FORMAT=DYNAMIC') | |
create_table_without_innodb_row_format(table_name, table_options) do |td| | |
yield td if block_given? | |
end | |
end | |
alias_method_chain :create_table, :innodb_row_format | |
end | |
end | |
end | |
# application.rb | |
config.time_zone = 'Tokyo' | |
config.active_record.default_timezone = :local | |
config.i18n.default_locale = :ja + locales/ja.yml | |
config.autoload_paths += %W(#{config.root}/lib) | |
# production.rb | |
config.log_level = :info | |
# plugins.rb lib/plugins/tx_around_action.rb + その他 | |
require 'plugins/tx_around_action' | |
# filter_parameter_loggingの検討 | |
# lib/capistrano/tasks delete_test_apps, confirm, log_rotate | |
# cap init + CapFileコメントアウト(assets, bundler, rvm) + wheneverとか | |
# application_controller | |
# lib/api_error.rb | |
# protect_from_forgery | |
# staging | |
# environments/staging.rb | |
# secrets.yml | |
# database.yml | |
# seed初期化 | |
def initialize_master_table(model) | |
(model.respond_to?(:delete_all!)) ? model.delete_all! : model.destroy_all | |
model.connection.execute("alter table #{model.table_name} AUTO_INCREMENT = 1;") | |
end | |
# settingslogic | |
# config/setting.yml | |
defaults: &defaults | |
development: | |
<<: *defaults | |
test: | |
<<: *defaults | |
staging: | |
<<: *defaults | |
production: | |
<<: *defaults | |
# setting.rb | |
class Setting < Settingslogic | |
source "#{Rails.root}/config/setting.yml" | |
namespace Rails.env | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment