Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.