mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
54 lines
1.3 KiB
Ruby
54 lines
1.3 KiB
Ruby
class Admin::CategoriesController < Admin::AdminController
|
|
|
|
def index
|
|
@categories = Category.all
|
|
end
|
|
|
|
def new
|
|
@category = Category.new
|
|
end
|
|
|
|
def edit
|
|
@category = Category.find(params[:id])
|
|
end
|
|
|
|
def update
|
|
@category = Category.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
if @category.update_attributes(params[:category])
|
|
format.html { redirect_to(admin_categories_path, :notice => 'Category was successfully updated.') }
|
|
format.xml { head :ok }
|
|
else
|
|
format.html { render :action => "edit" }
|
|
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
def create
|
|
@category = Category.new(params[:category])
|
|
|
|
respond_to do |format|
|
|
if @category.save
|
|
format.html { redirect_to(admin_categories_path, :notice => 'Category was successfully added.') }
|
|
format.xml { head :ok }
|
|
else
|
|
format.html { render :action => "edit" }
|
|
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@category = Category.find(params[:id])
|
|
@category.destroy
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to(admin_categories_path, :notice => 'Category was deleted.') }
|
|
format.xml { head :ok }
|
|
end
|
|
end
|
|
|
|
end
|