orbit-basic/app/controllers/admin/homes_controller.rb

51 lines
912 B
Ruby

class Admin::HomesController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
def show
#TODO
end
def new
@home = Home.new
@home.is_published = true
@home.parent_id = nil
end
def edit
@home = Home.find(params[:id])
@i18n_variable = @home.i18n_variable
end
def create
@home = Home.new(params[:home])
if @home.save
flash[:notice] = t('admin.create_success_home')
redirect_to admin_items_url
else
render :action => "new"
end
end
def update
@home = Home.find(params[:id])
if @home.update_attributes(params[:home])
flash[:notice] = t('admin.update_success_home')
redirect_to admin_items_url
else
render :action => "edit"
end
end
def destroy
@home = Home.find(params[:id])
@home.destroy
redirect_to admin_items_url
end
end