Add asset model and controller
This commit is contained in:
1 parent
d5c5200b71
commit
a19e0dba6c
15 files changed
+290
-2
No files matched your search
@@ -0,0 +1,51 @@
|
||||
class Admin::AssetsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
|
||||
def show
|
||||
@asset = Asset.find(params[:id])
|
||||
send_data @asset.data.file.read, :filename => @asset.filename,
|
||||
:type => @asset.data.content_type,
|
||||
:disposition => 'inline' # or 'attachment'
|
||||
end
|
||||
|
||||
def index
|
||||
@assets = Asset.find(:all)
|
||||
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
|
||||
Reference in new issue
Block a user