Skip to content

Commit

Permalink
Migrate from SProckets and turbolinks to Turbo and Propshaft (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
anko20094 authored Oct 31, 2022
1 parent 827b5a2 commit b95150b
Show file tree
Hide file tree
Showing 53 changed files with 1,571 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.3
3.1.2
4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.2.4.cjs
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.3'
ruby '3.1.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 7.0', '>= 7.0.4'
Expand All @@ -15,12 +15,13 @@ gem 'puma', '~> 6.0'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'cssbundling-rails', '~> 1.1', '>= 1.1.1'
gem 'jsbundling-rails', '~> 1.0', '>= 1.0.3'
gem 'sprockets-rails', '~> 3.4', '>= 3.4.2'
gem 'propshaft', '~> 0.6.4'
gem 'turbo-rails', '~> 1.3', '>= 1.3.2'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
gem 'bcrypt', '~> 3.1.7'

Expand Down Expand Up @@ -67,4 +68,4 @@ group :development do
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
gem 'tzinfo-data' # , platforms: %i[mingw mswin x64_mingw jruby]
37 changes: 21 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ GEM
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.16.3)
msgpack (1.6.0)
net-imap (0.3.1)
Expand All @@ -177,15 +178,19 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.9-x64-mingw32)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-linux)
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
pagy (5.10.1)
activesupport
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
propshaft (0.6.4)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
railties (>= 7.0.0)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -276,19 +281,16 @@ GEM
rack (~> 2.0)
redis (>= 4.5.0, < 5)
smart_properties (1.17.0)
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.5.3-x64-mingw32)
sqlite3 (1.5.3-x86_64-linux)
sqlite3 (1.5.3)
mini_portile2 (~> 2.8.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.1)
timeout (0.3.0)
turbo-rails (1.3.2)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2022.6)
Expand All @@ -303,10 +305,11 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.1)
zeitwerk (2.6.3)
zlib (2.1.1)

PLATFORMS
x64-mingw-ucrt
x64-mingw32
x86_64-linux

Expand All @@ -328,26 +331,28 @@ DEPENDENCIES
letter_opener
lokalise_rails (~> 5.1)
pagy (~> 5.0)
propshaft (~> 0.6.4)
pry-rails
puma (~> 6.0)
pundit (~> 2.1)
rack-mini-profiler (~> 3.0)
rails (~> 7.0, >= 7.0.4)
rails-i18n (~> 7.0, >= 7.0.5)
redis (~> 4.0)
rubocop (~> 1.18)
rubocop-i18n (~> 3)
rubocop-performance (~> 1.11)
rubocop-rails (~> 2.11)
rubyXL (~> 3.4)
rubyzip (~> 2)
sidekiq (~> 6.5, >= 6.5.7)
sprockets-rails (~> 3.4, >= 3.4.2)
sqlite3 (~> 1.4)
turbo-rails (~> 1.3, >= 1.3.2)
tzinfo-data
web-console (>= 4.1.0)

RUBY VERSION
ruby 3.0.3p157
ruby 3.1.2p20

BUNDLED WITH
2.3.24
2.3.7
3 changes: 0 additions & 3 deletions app/assets/config/manifest.js

This file was deleted.

8 changes: 4 additions & 4 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def index
end
end

def edit; end

def create
if params[:archive].present?
UserBulkImportJob.perform_later create_blob, current_user
Expand All @@ -30,8 +32,6 @@ def create
redirect_to admin_users_path
end

def edit; end

def update
if @user.update user_params
flash[:success] = t '.success'
Expand All @@ -44,7 +44,7 @@ def update
def destroy
@user.destroy
flash[:success] = t '.success'
redirect_to admin_users_path
redirect_to admin_users_path, status: :see_other
end

private
Expand All @@ -71,4 +71,4 @@ def authorize_user!
authorize(@user || User)
end
end
end
end
20 changes: 10 additions & 10 deletions app/controllers/answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ class AnswersController < ApplicationController
before_action :authorize_answer!
after_action :verify_authorized

def update
if @answer.update answer_update_params
flash[:success] = t '.success'
redirect_to question_path(@question, anchor: dom_id(@answer))
else
render :edit
end
end

def edit; end

def create
Expand All @@ -32,10 +23,19 @@ def create
end
end

def update
if @answer.update answer_update_params
flash[:success] = t '.success'
redirect_to question_path(@question, anchor: dom_id(@answer))
else
render :edit, status: :unprocessable_entity
end
end

def destroy
@answer.destroy
flash[:success] = t '.success'
redirect_to question_path(@question)
redirect_to question_path(@question), status: :see_other
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def destroy

comment.destroy
flash[:success] = t '.success'
redirect_to question_path(@question)
redirect_to question_path(@question), status: :see_other
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/password_resets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class PasswordResetsController < ApplicationController
before_action :check_user_params, only: %i[edit update]
before_action :set_user, only: %i[edit update]

def edit; end

def create
@user = User.find_by email: params[:email]

Expand All @@ -18,8 +20,6 @@ def create
redirect_to new_session_path
end

def edit; end

def update
if @user.update user_params
flash[:success] = t '.success'
Expand All @@ -45,4 +45,4 @@ def set_user

redirect_to(new_session_path, flash: { warning: t('.fail') }) unless @user&.password_reset_period_valid?
end
end
end
42 changes: 21 additions & 21 deletions app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,47 @@ class QuestionsController < ApplicationController
before_action :authorize_question!
after_action :verify_authorized

def index
@tags = Tag.where(id: params[:tag_ids]) if params[:tag_ids]
@pagy, @questions = pagy Question.all_by_tags(@tags)
@questions = @questions.decorate
end

def show
load_question_answers
end

def destroy
@question.destroy
flash[:success] = t('.success')
redirect_to questions_path
def new
@question = Question.new
end

def edit; end

def update
if @question.update question_params
def create
@question = current_user.questions.build question_params
if @question.save
flash[:success] = t('.success')
redirect_to questions_path
else
render :edit
render :new, status: :unprocessable_entity
end
end

def index
@tags = Tag.where(id: params[:tag_ids]) if params[:tag_ids]
@pagy, @questions = pagy Question.all_by_tags(@tags)
@questions = @questions.decorate
end

def new
@question = Question.new
end

def create
@question = current_user.questions.build question_params
if @question.save
def update
if @question.update question_params
flash[:success] = t('.success')
redirect_to questions_path
else
render :new
render :edit, status: :unprocessable_entity
end
end

def destroy
@question.destroy
flash[:success] = t('.success')
redirect_to questions_path, status: :see_other
end

private

def question_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
def destroy
sign_out
flash[:success] = t '.success'
redirect_to root_path
redirect_to root_path, status: :see_other
end

private
Expand Down
22 changes: 11 additions & 11 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@ class UsersController < ApplicationController
before_action :authorize_user!
after_action :verify_authorized

def edit; end

def update
if @user.update user_params
flash[:success] = t '.success'
redirect_to edit_user_path(@user)
else
render :edit
end
end

def new
@user = User.new
end

def edit; end

def create
@user = User.new user_params
if @user.save
Expand All @@ -33,6 +24,15 @@ def create
end
end

def update
if @user.update user_params
flash[:success] = t '.success'
redirect_to edit_user_path(@user)
else
render :edit
end
end

private

def set_user!
Expand Down
6 changes: 2 additions & 4 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Entry point for the build script in your package.json

import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import "@hotwired/turbo-rails"
import * as ActiveStorage from "@rails/activestorage"

import 'bootstrap/js/dist/dropdown'
import 'bootstrap/js/dist/collapse'
import './scripts/select'

Rails.start()
Turbolinks.start()
ActiveStorage.start()

Loading

0 comments on commit b95150b

Please sign in to comment.