diff --git a/.gitignore b/.gitignore index f92525ca..3d80232f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ # Ignore master key for decrypting credentials and more. /config/master.key + +# Ignore IDE config files +.idea/ diff --git a/Gemfile b/Gemfile index 777af1b8..3a81224e 100644 --- a/Gemfile +++ b/Gemfile @@ -55,6 +55,7 @@ group :development, :test do end group :development do + gem "hotwire-spark" # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" end diff --git a/Gemfile.lock b/Gemfile.lock index 8946eb2b..22660e83 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,11 +116,23 @@ GEM factory_bot_rails (6.4.4) factory_bot (~> 6.5) railties (>= 5.0.0) + ffi (1.17.1-aarch64-linux-gnu) + ffi (1.17.1-aarch64-linux-musl) + ffi (1.17.1-arm-linux-gnu) + ffi (1.17.1-arm-linux-musl) + ffi (1.17.1-arm64-darwin) + ffi (1.17.1-x86_64-darwin) + ffi (1.17.1-x86_64-linux-gnu) + ffi (1.17.1-x86_64-linux-musl) fugit (1.11.1) et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) + hotwire-spark (0.1.13) + listen + rails (>= 7.0.0) + zeitwerk i18n (1.14.7) concurrent-ruby (~> 1.0) importmap-rails (2.1.0) @@ -148,6 +160,9 @@ GEM thor (~> 1.3) zeitwerk (>= 2.6.18, < 3.0) language_server-protocol (3.17.0.4) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) logger (1.6.5) loofah (2.24.0) crass (~> 1.0.2) @@ -253,6 +268,9 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) rdoc (6.11.0) psych (>= 4.0.0) regexp_parser (2.10.0) @@ -378,6 +396,7 @@ PLATFORMS arm-linux-gnu arm-linux-musl arm64-darwin-24 + x86_64-darwin-23 x86_64-darwin-24 x86_64-linux x86_64-linux-gnu @@ -390,6 +409,7 @@ DEPENDENCIES capybara debug factory_bot_rails + hotwire-spark importmap-rails jbuilder kamal diff --git a/app/controllers/regions_controller.rb b/app/controllers/regions_controller.rb new file mode 100644 index 00000000..1b6b548e --- /dev/null +++ b/app/controllers/regions_controller.rb @@ -0,0 +1,65 @@ +class RegionsController < ApplicationController + before_action :set_region, only: %i[ show edit update destroy ] + + # GET /regions + def index + @regions = Region.all + end + + # GET /regions/1 + def show + end + + # GET /regions/new + def new + @region = Region.new + end + + # GET /regions/1/edit + def edit + end + + # POST /regions + def create + @region = Region.new(region_params) + + respond_to do |format| + if @region.save + format.html { redirect_to @region, notice: "Region was successfully created." } + else + format.html { render :new, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /regions/1 + def update + respond_to do |format| + if @region.update(region_params) + format.html { redirect_to @region, notice: "Region was successfully updated." } + else + format.html { render :edit, status: :unprocessable_entity } + end + end + end + + # DELETE /regions/1 + def destroy + @region.destroy! + + respond_to do |format| + format.html { redirect_to regions_path, status: :see_other, notice: "Region was successfully destroyed." } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_region + @region = Region.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def region_params + params.expect(region: [ :name ]) + end +end diff --git a/app/models/region.rb b/app/models/region.rb new file mode 100644 index 00000000..491c0b45 --- /dev/null +++ b/app/models/region.rb @@ -0,0 +1,3 @@ +class Region < ApplicationRecord + validates :name, presence: true +end diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index b8ee5cff..8c1bce96 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -55,11 +55,10 @@