diff --git a/Gemfile b/Gemfile index 6cc0b91..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' @@ -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 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 diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..e69de29 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/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] 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 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/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. diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 1a51ddf..084ac0e 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 +XkmYIxn7/p5YvPqWn64w1UrKz2aAMyEITFovMBeAghv+sqKVytVci3FqOfEuyXkVS1HGPM+jGfMd3eDx5dxTvW0T2LtSliuFTjw1vePziHJq7Eo7qgFrp1TGhgSdJZUjGiBJylsp5y8lvPHd+zHVYoS9xygt4++WOWvUI4mghtYT7NkCNd8GRjZkalcbWkUSbqoZnf+ARqJeJIRTwpxHvbOWD8qo7aTijUQRF+dMjT58gQpelgDHSJF1ISstnoes8MMsky6lW0c7IYZUtofsmLBS2ZlDuKWsXV9Ai5mevIDmUG64FRFTnZp7WxKadvIEU25/BvyT/qWRcOb7TmFm7db0EPwAwHdjkoEQng9r71yVgLIxMjfWlF3vsU2r1lyuZBvPOAEaPKVE5OPaY6wv7V66vCJqy7rTvBD4--a083M/Ot7evGs44m--ncBopitz5lfsX0ntiZ2v2Q== \ No newline at end of file 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' 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