Created
August 27, 2013 15:19
-
-
Save svs/6354982 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module GamesController | |
class Index < ControllerAction | |
def get | |
[200, {}, Game.all.to_json] | |
end | |
def params | |
super.except(:deleted_at) # no need for strong_params. specify what goes and what doesn't by overriding the params | |
end | |
end | |
class Create < ControllerAction | |
def post | |
@game = Game.create(params[:game]) | |
[200, {}, @game.to_json] | |
end | |
end | |
class Update < ControllerAction | |
def put | |
@game = Game.get(params[:id]) | |
@game.update(params["game"]) | |
@game.valid? ? [200,{}, @game.attributes] : [422,{},@game.errors] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment