blog_perso_app/app/controllers/admin/albums_controller.rb
Nicolas Bally ef2a73636b initial 2
2015-02-24 23:47:26 +01:00

44 lines
753 B
Ruby

# -*- encoding : utf-8 -*-
class Admin::AlbumsController < ApplicationController
def new
@album = Album.new()
end
def create
@album = Album.new(params.require(:album).permit!)
@album_create = true
if @album.save
@albums = Album.all.order(:name)
else
render :action => :new
end
end
def edit
@album = Album.find(params[:id])
end
def update
@album = Album.find(params[:id])
@album_update = true
if @album.update_attributes(params.require(:album).permit!)
@albums = Album.all(:order => :name)
else
render :action => :edit
end
end
def destroy
@album = Album.find(params[:id])
if @album.id != 1
@album.delete
end
end
end