Class: Admin::AssetsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::AssetsController
- Defined in:
- app/controllers/wafflemix/admin/assets_controller.rb
Instance Method Summary collapse
- #add_image ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#add_image ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 81 def add_image = params[:resource].constantize.find(params[:resource_id]) asset = Asset.find(params[:asset_id]) respond_to do |format| if .assets << asset format.js else format.js end end end |
#create ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 39 def create @asset = Asset.new(params[:asset]) if @asset.save respond_to do |format| format.html { render :json => [@asset.to_jq_upload].to_json, :content_type => 'text/html', :layout => false } format.json { render :json => [@asset.to_jq_upload].to_json } end else render :json => [{:error => "custom_failure"}], :status => 304 end end |
#destroy ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 71 def destroy @asset = Asset.find(params[:id]) @asset.destroy respond_to do |format| format.html { redirect_to admin_assets_path } format.json { head :no_content } end end |
#edit ⇒ Object
35 36 37 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 35 def edit @asset = Asset.find(params[:id]) end |
#index ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 8 def index @assets = Asset.all respond_to do |format| format.html format.json { render :json => @assets.collect { |p| p.to_jq_upload }.to_json } end end |
#new ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 26 def new @asset = Asset.new respond_to do |format| format.html format.json { render json: @asset } end end |
#show ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 17 def show @asset = Asset.find(params[:id]) respond_to do |format| format.html format.json { render json: @asset } end end |
#update ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/wafflemix/admin/assets_controller.rb', line 57 def update @asset = Asset.find(params[:id]) respond_to do |format| if @asset.update_attributes(params[:asset]) format.html { redirect_to [:admin, @asset], notice: 'Asset was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @asset.errors, status: :unprocessable_entity } end end end |