1
0
mirror of https://github.com/danbee/my-images synced 2025-03-04 08:49:05 +00:00
my-images/app/controllers/albums_controller.rb
2024-03-25 20:26:50 -05:00

28 lines
486 B
Ruby

class AlbumsController < ApplicationController
before_action :authenticate_user!
def index
@albums = @current_user.albums
end
def create
@album = Album.create(permitted_params)
@current_user.albums << @album
redirect_to albums_path
end
def destroy
album = @current_user.albums.find(params[:id])
album.destroy
redirect_to user_albums_path
end
private
def permitted_params
params.require(:album).permit(:user_id, :title)
end
end