Created
May 23, 2018 15:19
-
-
Save austinklenk/67f0d4af4c15a79d6c8da5a2ef6247d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
@albums = Album.all.with_attached_images | |
end | |
def show | |
authorize! :show, @album | |
@album = Album.friendly.find(params[:id]) | |
end | |
def new | |
authorize! :new, @album | |
@gallery = Gallery.find(params[:gallery_id]) | |
@album = @gallery.albums.build | |
end | |
def edit | |
authorize! :edit, @album | |
end | |
def create | |
authorize! :create, @album | |
@album = Album.new(album_params) | |
respond_to do |format| | |
if @album.save | |
format.html { redirect_to @album, notice: 'Album was successfully created.' } | |
else | |
format.html { render :new } | |
end | |
end | |
end | |
def update | |
authorize! :update, @album | |
respond_to do |format| | |
if @album.update(album_params) | |
format.html { redirect_to @album, notice: 'Album was successfully updated.' } | |
format.json { render :show, status: :ok, location: @album } | |
else | |
format.html { render :edit } | |
end | |
end | |
end | |
def destroy | |
authorize! :destroy, @album | |
@album.destroy | |
respond_to do |format| | |
format.html { redirect_to root_url, notice: 'Album was successfully destroyed.' } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment