Skip to content

Instantly share code, notes, and snippets.

@tpendragon
Last active December 18, 2015 00:59
Show Gist options
  • Save tpendragon/5700984 to your computer and use it in GitHub Desktop.
Save tpendragon/5700984 to your computer and use it in GitHub Desktop.
# before, would depend on routing constraints to block .json/.xml as 404 not found
class ThingyController < ApplicationController
def show
@thingy = Thingy.find params[:id]
end
def update
@thingy = Thingy.find params[:id]
if @thingy.update_attributes(params[:thingy])
redirect_to thingy_path, notice: "Your Thingy was successfully updated."
else
render :show
end
end
end
# after, uses respond_to and respond_with to respond with 406 unacceptable
class ThingyController < ApplicationController
respond_to :html
def show
@thingy = Thingy.find params[:id]
respond_with(@thingy)
end
def update
@thingy = Thingy.find params[:id]
@thingy.update_attributes(params[:thingy])
respond_with(@thingy)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment