Skip to content

Instantly share code, notes, and snippets.

@svs
Created August 27, 2013 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svs/6354982 to your computer and use it in GitHub Desktop.
Save svs/6354982 to your computer and use it in GitHub Desktop.
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