Last active
December 18, 2015 00:59
-
-
Save tpendragon/5700984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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