51 lines
		
	
	
		
			803 B
		
	
	
	
		
			Ruby
		
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			803 B
		
	
	
	
		
			Ruby
		
	
	
	
| class Admin::AssetsController < ApplicationController
 | |
| 
 | |
|   layout "admin"
 | |
|   before_filter :authenticate_user!
 | |
|   before_filter :is_admin?
 | |
|   
 | |
|   def index
 | |
|     @assets = Asset.all.entries
 | |
|   end
 | |
|   
 | |
|   def show
 | |
|   #TODO
 | |
|   end
 | |
|   
 | |
|   def edit
 | |
|     @asset = Asset.find(params[:id])
 | |
|   end
 | |
|   
 | |
|   def new
 | |
|     @asset = Asset.new
 | |
|   end
 | |
|   
 | |
|   def create  
 | |
|     @asset = Asset.new(params[:asset])
 | |
|     if @asset.save
 | |
|       redirect_to admin_assets_url
 | |
|     else
 | |
|       render :action => :new
 | |
|     end
 | |
|     
 | |
|   end
 | |
|   
 | |
|   def update
 | |
|     @asset = Asset.find(params[:id])
 | |
|     if @asset.update_attributes(params[:asset])
 | |
|       redirect_to admin_assets_url
 | |
|     else
 | |
|       render :action => :edit
 | |
|     end
 | |
|     
 | |
|   end
 | |
|     
 | |
|   def destroy
 | |
|     @asset = Asset.find(params[:id])
 | |
|     @asset.destroy
 | |
|     
 | |
|     redirect_to admin_assets_url
 | |
|   end
 | |
|   
 | |
| end
 |