Sha256: c11e8abce1d3c39c6d800575933bdf506245d624afc6f79ecfca47b741e96492

Contents?: true

Size: 1.04 KB

Versions: 19

Compression:

Stored size: 1.04 KB

Contents

class Api::OtherObjectsController < ApplicationController

  # Api::OtherObject

  before_filter do
    nested_in_resources = params.select{ |param| /_id$/ =~ param }
    params[:other_object].merge!(nested_in_resources)
    @resource = Api::OtherObject.where(nested_in_resources) if nested_in_resources.present?
  end

  def index
    render json: @other_objects = @resource.all
  end

  def create
    render json: if (@other_object = Api::OtherObject.create(params[:other_object]))
      @other_object
    else
      flash.now "Something bad Happened"
    end
  end

  def show
    render json: @other_object = Api::OtherObject.find(params[:id])
  end

  def update
    @other_object = Api::OtherObject.find(params[:id])
    render json: if @other_object.update_attributes(params[:other_object])
      @other_object
    else
      "Something bad Happened"
    end
  end

  def destroy
    @other_object = Api::OtherObject.find(params[:id])
    render json: if @other_object.delete
      { success: true }
    else
      "Something bad Happened"
    end
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
restly-0.0.1.beta.10 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.beta.9 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.beta.6 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.beta.5 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.beta.4 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.beta.3 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.beta.2 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.beta.1 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.22 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.19 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.18 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.16 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.12 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.11 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.10 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.9 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.8 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.7 spec/dummy/app/controllers/api/other_objects_controller.rb
restly-0.0.1.alpha.6 spec/dummy/app/controllers/api/other_objects_controller.rb