Class: Forge::AssetsController
Instance Method Summary
collapse
#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor
#app_init
Instance Method Details
#create ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 31
def create
@asset = Asset.new(params[:asset])
@asset.swfupload_file!(params[:Filedata], params[:Filename])
if @asset.save
render :json => {:id => @asset.id, :url => @asset.icon_path}
else
render :json => {:errors => @asset.errors.full_messages.to_sentence }
end
end
|
#destroy ⇒ Object
42
43
44
45
46
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 42
def destroy
@asset.destroy
flash[:notice] = "Asset deleted successfully!"
redirect_to forge_assets_path
end
|
#drawer ⇒ Object
Methods dealing with the drawer, placing, and setting ###
67
68
69
70
71
72
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 67
def drawer
@assets = Asset.for_drawer(params)
respond_to do |format|
format.js { render :partial => "drawer_asset", :collection => @assets }
end
end
|
#edit ⇒ Object
23
24
25
26
27
28
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 23
def edit
respond_to do |format|
format.html {}
format.js { render :layout => false }
end
end
|
#index ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 12
def index
respond_to do |format|
format.html { @assets = Asset.paginate(:per_page => 20, :page => params[:page]) }
format.js {
params[:q] ||= ''
@assets = Asset.includes(:tags).where("LOWER(assets.title) LIKE ? OR LOWER(tags.name) LIKE ?", "%#{params[:q].downcase}%", "%#{params[:q].downcase}%").references(:tags)
render :partial => "asset", :collection => @assets
}
end
end
|
#new ⇒ Object
6
7
8
9
10
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 6
def new
respond_to do |format|
format.js { render :layout => false }
end
end
|
#place ⇒ Object
80
81
82
83
84
85
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 80
def place
@options = params[:options]
respond_to do |format|
format.js { render :layout => false }
end
end
|
#prepare ⇒ Object
74
75
76
77
78
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 74
def prepare
respond_to do |format|
format.js { render :layout => false }
end
end
|
#show ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 57
def show
respond_to do |format|
format.js {
partial = params[:drawer] ? "drawer_asset" : "asset"
render :status => 200, :partial => partial, :locals => {:asset => @asset}
}
end
end
|
#update ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/forge/app/controllers/forge/assets_controller.rb', line 48
def update
if @asset.update_attributes(params[:asset])
flash[:notice] = "Asset updated succesfully."
redirect_to forge_assets_path
else
render :action => :edit
end
end
|