55 lines
		
	
	
		
			994 B
		
	
	
	
		
			Ruby
		
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			994 B
		
	
	
	
		
			Ruby
		
	
	
	
| class Admin::LayoutsController < ApplicationController
 | |
|   
 | |
|   layout "admin"
 | |
|   before_filter :authenticate_user!
 | |
|   before_filter :is_admin?
 | |
|   
 | |
|   def index
 | |
|     @layouts = Layout.all.entries
 | |
|   end
 | |
| 
 | |
|   def show
 | |
|     #TODO
 | |
| #    @layout = Layout.find(params[:id])
 | |
| #    redirect_to "/#{@layout.name}"
 | |
|   end
 | |
| 
 | |
|   def new
 | |
|     @layout = Layout.new
 | |
|   end
 | |
| 
 | |
|   def edit
 | |
|     @layout = Layout.find(params[:id])
 | |
|   end
 | |
| 
 | |
|   def create
 | |
|     @layout = Layout.new(params[:layout])
 | |
| 
 | |
|     if @layout.save
 | |
|       flash[:notice] = t('admin.create_success_layout')
 | |
|       redirect_to admin_layouts_url
 | |
|     else
 | |
|       render :action => 'new'
 | |
|     end
 | |
|   end
 | |
| 
 | |
|   def update
 | |
|     @layout = Layout.find(params[:id])
 | |
|     
 | |
|     if @layout.update_attributes(params[:layout])
 | |
|       flash[:notice] = t('admin.update_success_layout')
 | |
|       redirect_to admin_layouts_url
 | |
|     else
 | |
|       render :action => "edit"
 | |
|     end
 | |
|   end
 | |
| 
 | |
|   def destroy
 | |
|     @layout = Layout.find(params[:id])
 | |
|     @layout.destroy
 | |
| 
 | |
|     redirect_to admin_layouts_url
 | |
|   end
 | |
|   
 | |
| end
 |