Class: Wafflemix::AssetsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Wafflemix::AssetsController
- Defined in:
- app/controllers/wafflemix/assets_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/controllers/wafflemix/assets_controller.rb', line 38 def create @asset = Asset.new(params[:asset]) if @asset.save render :json => {image: {url: "#{@asset.asset.url}"}} else render :json => [{:error => "custom_failure"}], :status => 304 end end |
#destroy ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/wafflemix/assets_controller.rb', line 61 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
34 35 36 |
# File 'app/controllers/wafflemix/assets_controller.rb', line 34 def edit @asset = Asset.find(params[:id]) end |
#index ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/controllers/wafflemix/assets_controller.rb', line 7 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
25 26 27 28 29 30 31 32 |
# File 'app/controllers/wafflemix/assets_controller.rb', line 25 def new @asset = Asset.new respond_to do |format| format.html format.json { render json: @asset } end end |
#show ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/wafflemix/assets_controller.rb', line 16 def show @asset = Asset.find(params[:id]) respond_to do |format| format.html format.json { render json: @asset } end end |
#update ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/wafflemix/assets_controller.rb', line 47 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 |