diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 95f2992..4f84207 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,6 @@ class HomeController < ApplicationController + skip_before_action :authenticate + def index end end diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index e9376f1..e2b09f6 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -1,8 +1,8 @@ class VehiclesController < ApplicationController before_action :set_vehicle, only: %i[ show edit update destroy ] skip_before_action :authenticate - - #has_many_attached :images + + # has_many_attached :images # GET /vehicles or /vehicles.json def index @@ -68,6 +68,6 @@ class VehiclesController < ApplicationController # Only allow a list of trusted parameters through. def vehicle_params - params.require(:vehicle).permit(:vehicle_type, :car_brand, :model, :model_year, :fuel_type, :power_ps, :power_kw, :registered, :license_plate, :color, :note) + params.require(:vehicle).permit(:vehicle_type, :car_brand, :model, :model_year, :fuel_type, :power_ps, :power_kw, :registered, :license_plate, :color, :note, images: []) end end diff --git a/app/models/vehicle.rb b/app/models/vehicle.rb index 34ee24c..a5c64da 100644 --- a/app/models/vehicle.rb +++ b/app/models/vehicle.rb @@ -1,3 +1,10 @@ class Vehicle < ApplicationRecord - enum vehicle_type: { car: 0, truck: 1, motorcycle: 2, van: 3} + has_many_attached :images do |attachable| + attachable.variant :thumb, resize_to_limit: [ 100, 100 ] + attachable.variant :medium, resize_to_limit: [ 600, 600 ] + attachable.variant :big, resize_to_limit: [ 1000, 1000 ] + attachable.variant :hugh, resize_to_limit: [ 1920, 1920 ] + end + + enum vehicle_type: { car: 0, truck: 1, motorcycle: 2, van: 3 } end diff --git a/app/views/vehicles/_form.html.erb b/app/views/vehicles/_form.html.erb index f49debc..74e0da3 100644 --- a/app/views/vehicles/_form.html.erb +++ b/app/views/vehicles/_form.html.erb @@ -9,6 +9,13 @@ <% end %> +
Bilder: + <% vehicle.images.each do |image| %> + <%= image_tag image.variant(:medium) %> + <% end %> +
Angemeldet: <%= vehicle.registered %>