Skip to content

Instantly share code, notes, and snippets.

@mrmemes-eth
Created September 30, 2010 22:19
Show Gist options
  • Save mrmemes-eth/605430 to your computer and use it in GitHub Desktop.
Save mrmemes-eth/605430 to your computer and use it in GitHub Desktop.
class ThingsController < ApplicationController
respond_to :html, :json
# decent_exposure won't currently intuit a collection (plural resource) for you. The SLTD error is
# caused by a circular reference between an undeclared collection (which the singular resource attempts
# to scope from) and the singular resource. To fix this problem, just define the collection:
expose(:things) { Thing.all }
# or alternatively, something like:
# expose(:things) { current_user.things }
expose(:thing)
def create
thing.save
respond_with(thing)
end
def destroy
thing.destroy
respond_with(thing)
end
def update
thing.update_attributes(params[:thing])
respond_with(thing)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment