From 4bacd65dcc8d78a5eff6c2460eff09786f6d13f4 Mon Sep 17 00:00:00 2001 From: 23nith Date: Wed, 21 Sep 2022 14:46:01 +0800 Subject: [PATCH 1/8] Make corrections to sessions controller response to logout --- app/controllers/users/sessions_controller.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 773ccaf..3360920 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -13,17 +13,10 @@ def respond_with(resource, _opts = {}) end def respond_to_on_destroy - if current_user - render json: { - status: 200, - message: 'logged out successfully' - }, status: :ok - else - render json: { - status: 401, - message: "Couldn't find an active session." - }, status: :unauthorized - end + render json: { + status: 200, + message: 'logged out successfully' + }, status: :ok end # before_action :configure_sign_in_params, only: [:create] From 4e00bd3d99410bf6fcccaf8ee8b7cd8e7d12a7ae Mon Sep 17 00:00:00 2001 From: 23nith Date: Wed, 21 Sep 2022 14:46:46 +0800 Subject: [PATCH 2/8] Fix validation for rating --- app/models/list_item.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/list_item.rb b/app/models/list_item.rb index 0a58a43..048a77c 100644 --- a/app/models/list_item.rb +++ b/app/models/list_item.rb @@ -20,5 +20,5 @@ class ListItem < ApplicationRecord validates :book_id, presence: true validates :user_id, presence: true - validates :rating, presence: true, numericality: { in: 1..5 } + validates :rating, presence: true, numericality: { in: 0..5 } end From 6b4edcda3cdc34447a6050504c98cf0cf4090727 Mon Sep 17 00:00:00 2001 From: 23nith Date: Wed, 21 Sep 2022 20:51:59 +0800 Subject: [PATCH 3/8] Revise edit listItem endpoint --- app/controllers/api/v1/list_items_controller.rb | 8 ++++++-- config/routes.rb | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/list_items_controller.rb b/app/controllers/api/v1/list_items_controller.rb index 4729d11..18dd57d 100644 --- a/app/controllers/api/v1/list_items_controller.rb +++ b/app/controllers/api/v1/list_items_controller.rb @@ -32,7 +32,12 @@ def create end end + def edit + @list_item = ListItem.find(params[:id]) + end + def update + @list_item = ListItem.find(params[:id]) if @list_item.update(list_item_params) render json: @list_item else @@ -54,7 +59,6 @@ def set_list_item end def list_item_params - params.require(:list_item).permit(:id, :book_id, :user_id, :rating, :notes, :start_date, :finish_date, - :created_at, :updated_at) + params.require(:list_item).permit(:id, :book_id, :user_id, :rating, :notes, :start_date, :finish_date, :created_at, :updated_at) end end diff --git a/config/routes.rb b/config/routes.rb index d994a64..9f0773c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,8 +7,9 @@ get '/finished_books' => 'list_items#finished_books' post '/list_item' => 'list_items#show' post '/add_list_item' => 'list_items#create' - # post '/add_list_item' => 'list_items#add_list_item' - post '/edit_list_item' => 'list_items#update' + get '/list_item/:id/edit' => 'list_items#edit' + patch '/list_item/:id' => 'list_items#update' + delete '/list_item' => 'list_items#destroy' get '/books' => 'books#index' From ea49a5d6945e640ddeb02fbf5b866e51cccba179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C23nith=E2=80=9D?= <“zenithmanuel@gmail.comgit config --global user.email “ZENITHMANUEL@GMAIL.com> Date: Wed, 13 Mar 2024 17:40:43 +0800 Subject: [PATCH 4/8] Update credentials --- config/credentials.yml.enc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 1a51ddf..b967503 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -uxkWVScNcve1FirRzfI5llo6u5plSZaRzKwS2we1qCtiG8LBhE9A0q2aT7Fh+OkxPdqg/ycfNrLlXhHWdLZkXG8+kNnnyGbiS66lBUPJmspR9PI0q/I6ukC1W2LM4QxVC7HDGXv1RIzUMwq6LuahLbRSqQcVMBfdtUGWRw1e6PoAlBxW1L7HKnn76SaK3oMg19WNUZwcrkr2vdnLEvrkDBt3Xo0loDXg6PyQypGWUYFEJafDwtGEtEEhXVwxBkVQJmfoRvFr3jn8yp19c8fSzqGsVrHwN8RFhQApQFmvgpj0RxGvpz2xuB2DYUFFkh+7SwY2k5alNm8yjtQW919Mel1RViT/hNYPDGVilPLGDi3gMz/HFdNUbMdJvju31bA6271ZGheUqbcqMe9wkbjjJSdbDeiGVwVHl3Wt--1WJLuUAYx4FK//Sd--YfppxPSj1PolgCC0o2r23Q== \ No newline at end of file +pK0xLS6Fl8zXoZZSdHyGD0/W4kwdc7uy9GbL9bvvxKjJv3sedFuuvIj8T6lUPGPFP74WuxxWKoMa4xoB2mcxH2DyjjPCnbkBaEArn6YD3bBL73CeKNOceZSbC/K4GXzDBPd1M8drZnZU1samWjbz9mHvOAUKpgbeBtQ9WcFklp5TXbVpM3EOF/0aHblFwc+uD1DXGjCnUkGAPxAZcvcVqz3UeiemQKOZHinZkXPrVeI17nKbcH+XuuVFOSPsmEEvUJ7ZeUxReRYltb0ukVdG5lDJNESBKqUybYpcCF6UrZt9P1mXoIb7+UEI0ahZgUP5NTgncrUsOFvY3ttc9kGpj4zK11Ot8zdwTw4GjiV4ddxuVDWTSL8q4+zrenfghs2s8dhvh/zGcv/6IhBvdYuELyGpONvOZGaEkvWx--A4rfvlfJCoK599OI--clC/+k+4QjSV9TIz+xlESw== \ No newline at end of file From 744dc4e74340bdd9cdc974ec3bc34699bac43fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C23nith=E2=80=9D?= <“zenithmanuel@gmail.comgit config --global user.email “ZENITHMANUEL@GMAIL.com> Date: Wed, 13 Mar 2024 17:52:38 +0800 Subject: [PATCH 5/8] Fix assets:precompile error on deployment --- app/assets/config/manifest.js | 0 config/application.rb | 1 + 2 files changed, 1 insertion(+) create mode 100644 app/assets/config/manifest.js diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..e69de29 diff --git a/config/application.rb b/config/application.rb index f196e98..368c4ff 100644 --- a/config/application.rb +++ b/config/application.rb @@ -3,6 +3,7 @@ require_relative 'boot' require 'rails/all' +require 'sprockets/railtie' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. From bdf26a2122305c77853fd1f29aa69a4ce6856c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C23nith=E2=80=9D?= <“zenithmanuel@gmail.comgit config --global user.email “ZENITHMANUEL@GMAIL.com> Date: Wed, 13 Mar 2024 17:58:41 +0800 Subject: [PATCH 6/8] Add sprockets/railtie --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 6cc0b91..85ac381 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,7 @@ gem 'rack-cors' gem 'devise' gem 'devise-jwt' gem 'fast_jsonapi' +gem 'sprockets-rails' group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem From 280d49e93a89951decbab5b10d5f334aa90383d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C23nith=E2=80=9D?= <“zenithmanuel@gmail.comgit config --global user.email “ZENITHMANUEL@GMAIL.com> Date: Wed, 13 Mar 2024 18:02:16 +0800 Subject: [PATCH 7/8] Push gemfile and gemfile.lock files --- Gemfile | 2 +- Gemfile.lock | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 85ac381..bd03a79 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '3.1.1' +ruby '3.1.2' # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem 'rails', '~> 7.0.3' diff --git a/Gemfile.lock b/Gemfile.lock index abfd747..5581955 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -143,6 +143,8 @@ GEM net-protocol timeout nio4r (2.5.8) + nokogiri (1.13.6-arm64-darwin) + racc (~> 1.4) nokogiri (1.13.6-x86_64-linux) racc (~> 1.4) orm_adapter (0.5.0) @@ -227,6 +229,13 @@ GEM rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) ruby-progressbar (1.11.0) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) strscan (3.0.3) thor (1.2.1) timeout (0.3.0) @@ -246,6 +255,7 @@ GEM zeitwerk (2.6.0) PLATFORMS + arm64-darwin-22 x86_64-linux DEPENDENCIES @@ -263,10 +273,11 @@ DEPENDENCIES rails (~> 7.0.3) rspec-rails rubocop-rails + sprockets-rails tzinfo-data RUBY VERSION - ruby 3.1.1p18 + ruby 3.1.2p20 BUNDLED WITH 2.3.7 From e77fbb69016e3f2c381a5dde3f5987da95401123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C23nith=E2=80=9D?= Date: Thu, 25 Sep 2025 13:03:58 +0800 Subject: [PATCH 8/8] Changes for render redeployment --- bin/render-build.sh | 6 ++++++ config/credentials.yml.enc | 2 +- render.yaml | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 bin/render-build.sh create mode 100644 render.yaml diff --git a/bin/render-build.sh b/bin/render-build.sh new file mode 100644 index 0000000..d02a062 --- /dev/null +++ b/bin/render-build.sh @@ -0,0 +1,6 @@ +#/usr/bin/env bash# exit on error +set -o errexit + +bundle install +bundle exec rails assets:precompile +bundle exec rails assets:clean \ No newline at end of file diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index b967503..084ac0e 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -pK0xLS6Fl8zXoZZSdHyGD0/W4kwdc7uy9GbL9bvvxKjJv3sedFuuvIj8T6lUPGPFP74WuxxWKoMa4xoB2mcxH2DyjjPCnbkBaEArn6YD3bBL73CeKNOceZSbC/K4GXzDBPd1M8drZnZU1samWjbz9mHvOAUKpgbeBtQ9WcFklp5TXbVpM3EOF/0aHblFwc+uD1DXGjCnUkGAPxAZcvcVqz3UeiemQKOZHinZkXPrVeI17nKbcH+XuuVFOSPsmEEvUJ7ZeUxReRYltb0ukVdG5lDJNESBKqUybYpcCF6UrZt9P1mXoIb7+UEI0ahZgUP5NTgncrUsOFvY3ttc9kGpj4zK11Ot8zdwTw4GjiV4ddxuVDWTSL8q4+zrenfghs2s8dhvh/zGcv/6IhBvdYuELyGpONvOZGaEkvWx--A4rfvlfJCoK599OI--clC/+k+4QjSV9TIz+xlESw== \ No newline at end of file +XkmYIxn7/p5YvPqWn64w1UrKz2aAMyEITFovMBeAghv+sqKVytVci3FqOfEuyXkVS1HGPM+jGfMd3eDx5dxTvW0T2LtSliuFTjw1vePziHJq7Eo7qgFrp1TGhgSdJZUjGiBJylsp5y8lvPHd+zHVYoS9xygt4++WOWvUI4mghtYT7NkCNd8GRjZkalcbWkUSbqoZnf+ARqJeJIRTwpxHvbOWD8qo7aTijUQRF+dMjT58gQpelgDHSJF1ISstnoes8MMsky6lW0c7IYZUtofsmLBS2ZlDuKWsXV9Ai5mevIDmUG64FRFTnZp7WxKadvIEU25/BvyT/qWRcOb7TmFm7db0EPwAwHdjkoEQng9r71yVgLIxMjfWlF3vsU2r1lyuZBvPOAEaPKVE5OPaY6wv7V66vCJqy7rTvBD4--a083M/Ot7evGs44m--ncBopitz5lfsX0ntiZ2v2Q== \ No newline at end of file diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..138ff6e --- /dev/null +++ b/render.yaml @@ -0,0 +1,13 @@ +databases: +- name: mysite +databaseName: mysite user: mysite plan: free +services: +- type: web name: mysite runtime: ruby plan: free buildCommand: "./bin/render-build.sh" +# preDeployCommand: "bundle exec rails db:migrate" # preDeployCommand only available on paid instance types +startCommand: "bundle exec rails server" envars: +- key: DATABASE_URL fromDatabase: +name: mysite +property: connectionString +- key: RAILS_MASTER_KEY +sync: false- key: WEB_CONCURRENCY +value: 2 # sensible default \ No newline at end of file