下記のように書く。
redirect to('/inquiry/thanks')
リダイレクトのステータスはデフォルトで303(See Other)なのでこのまま。
redirect to('/inquiry/thanks')
Uncaught SyntaxError: Unexpected token varというエラーがでてjsが正しく動作しなかった。
assets do
serve '/javascripts', from: 'assets/javascripts'
serve '/stylesheets', from: 'assets/stylesheets'
js :application, [
'/javascripts/jquery-*.js',
'/javascripts/jquery.zclip.js',
'/javascripts/*.js',
'/javascripts/*.coffee'
]
css :application, [
'/stylesheets/*.css',
'/stylesheets/*.scss'
]
js_compression :closure, :level=>"WHITESPACE_ONLY" # :jsminだとbootstrap.jsないでエラーが起こる。closureにしても "WHITESPACE_ONLY"指定しないとだめ。
#js_compression :jsmin
css_compression :sass
end
group :development do
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails', '~> 1.1.3'
end
$ bin/cap install
namespace :deploy do
task :environment do
set :unicorn_pid, "#{shared_path}/tmp/pids/unicorn.pid"
set :unicorn_config, "#{current_path}/config/unicorn/unicorn_#{fetch(:rails_env)}.rb"
set :unicorn_path, "#{current_path}/bin/unicorn"
end
def start_unicorn
within current_path do
execute "#{fetch(:unicorn_path)} -c #{fetch(:unicorn_config)} -E #{fetch(:rails_env)} -D"
end
end
def stop_unicorn
execute :kill, "-s QUIT $(< #{fetch(:unicorn_pid)})"
end
def reload_unicorn
execute :kill, "-s USR2 $(< #{fetch(:unicorn_pid)})"
end
def force_stop_unicorn
execute :kill, "$(< #{fetch(:unicorn_pid)})"
end
desc "Start unicorn server"
task :start => :environment do
on roles(:app) do
start_unicorn
end
end
desc "Stop unicorn server gracefully"
task :stop => :environment do
on roles(:app) do
stop_unicorn
end
end
desc "Restart unicorn server gracefully"
task :restart => :environment do
on roles(:app) do
if test("[ -f #{fetch(:unicorn_pid)} ]")
reload_unicorn
else
start_unicorn
end
end
end
desc "Stop unicorn server immediately"
task :force_stop => :environment do
on roles(:app) do
force_stop_unicorn
end
end
end
end
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'
# require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, '#{app_name}'
set :repo_url, '#{repo_url}'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '#{deploy_path}'
set :bundle_flags, "--binstubs" # bundleにbinstubsオプションをつけている。
# Default value for :scm is :git
set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push( 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
set :keep_releases, 10
namespace :deploy do
after :restart, :clear_cache do
on roles(:app), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
after 'deploy:publishing', 'deploy:restart' # これ入れないとdeployした後にunicornに更新が読みこまれない。
end
set :rails_env, "production"
$ bin/cap production deploy