Skip to content

Instantly share code, notes, and snippets.

@paulelliott
Created March 11, 2011 02:03
Show Gist options
  • Save paulelliott/865338 to your computer and use it in GitHub Desktop.
Save paulelliott/865338 to your computer and use it in GitHub Desktop.
Merged create/update actions
class ComicsController < ApplicationController
respond_to :html
before_filter :authenticated
before_filter :authenticate_admin, except: :index
expose :comic
expose(:comics) do
User.find_by_username(params[:username]).try(:comics) || Comic.all
end
def create
respond_with(comic.tap(&:save))
end
alias update create
def destroy
comic.destroy
respond_with(comic)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment