picture cache for forms

This commit is contained in:
2023-01-22 20:40:28 +02:00
parent 0a9b32f06b
commit e4364fc677
7 changed files with 16 additions and 83 deletions

View File

@ -1,16 +1,13 @@
class EventsController < ApplicationController
before_action :set_event, only: %i[ show edit update destroy ]
# GET /events
def index
@events = Event.all
end
# GET /events/1
def show
end
# GET /events/new
def new
kind = params[:profile]
kind = Profile.kinds.first unless Profile.kinds.include?(kind)
@ -22,11 +19,9 @@ class EventsController < ApplicationController
end
end
# GET /events/1/edit
def edit
end
# POST /events
def create
@event = Event.new(event_params)
@ -37,7 +32,6 @@ class EventsController < ApplicationController
end
end
# PATCH/PUT /events/1
def update
if @event.update(event_params)
redirect_to @event, notice: "Event was successfully updated."
@ -60,6 +54,7 @@ class EventsController < ApplicationController
# Only allow a list of trusted parameters through.
def event_params
params.require(:event).permit(:name, :text, :start_date, :end_date, :profile_id, :picture)
params.require(:event).permit(:name, :text, :start_date, :end_date,
:profile_id, :picture, :picture_cache)
end
end

View File

@ -1,28 +1,23 @@
class ProfilesController < ApplicationController
before_action :set_profile, only: %i[ show edit update destroy ]
# GET /profiles
def index
@profiles = Profile.page params[:page]
end
# GET /profiles/1
def show
end
# GET /profiles/new
def new
kind = params[:kind]
kind = Profile.kinds.first unless Profile.kinds.include?(kind)
@profile = Profile.new kind: kind
end
# GET /profiles/1/edit
def edit
authorize @profile
end
# POST /profiles
def create
@profile = Profile.new(profile_params)
@profile.member = current_member
@ -34,7 +29,6 @@ class ProfilesController < ApplicationController
end
end
# PATCH/PUT /profiles/1
def update
authorize @profile
if @profile.update(profile_params)
@ -44,7 +38,6 @@ class ProfilesController < ApplicationController
end
end
# DELETE /profiles/1
def destroy
authorize @profile
@profile.destroy
@ -59,6 +52,6 @@ class ProfilesController < ApplicationController
# Only allow a list of trusted parameters through.
def profile_params
params.require(:profile).permit(:name, :bio, :picture, :kind)
params.require(:profile).permit(:name, :bio, :picture,:picture_cache, :kind)
end
end