first gallery version

This commit is contained in:
Torsten
2023-01-25 22:15:54 +02:00
parent 09500b8223
commit e7b24d1201
22 changed files with 304 additions and 12 deletions

View File

@ -0,0 +1,55 @@
class PicturesController < ApplicationController
before_action :set_picture, only: %i[ show edit update destroy ]
def index
@q = Picture.ransack(params[:q])
@q.sorts = 'created_at desc' if @q.sorts.empty?
@pictures = @q.result(distinct: true).page( params[:page])
end
def show
end
def new
@picture = Picture.new
end
def edit
authorize @picture
end
def create
@picture = Picture.new(picture_params)
@picture.member = current_member
if @picture.save
redirect_to @picture, notice: "Picture was successfully created."
else
render :new, status: :unprocessable_entity
end
end
def update
authorize @picture
if @picture.update(picture_params)
redirect_to @picture, notice: "Picture was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
authorize @picture
@picture.destroy
redirect_to pictures_url, notice: "Picture was successfully destroyed."
end
private
def set_picture
@picture = Picture.find(params[:id])
end
def picture_params
params.require(:picture).permit(:picture,:picture_cache ,:text, :member_id)
end
end

View File

@ -45,13 +45,11 @@ class StoriesController < ApplicationController
end
private
# Use callbacks to share common setup or constraints between actions.
def set_story
@story = Story.find(params[:id])
end
# Only allow a list of trusted parameters through.
def story_params
params.require(:story).permit(:picture, :header, :text, :happened)
params.require(:story).permit(:picture,:picture_cache, :header, :text, :happened)
end
end