where to put code for all methods in a Controller

add a before_filter that does this (you'll want to use an instance variable for kind instead of a local variable

Fred

'Adding code' at the top tries to execute the code in the context of the controller class. Code added at the top level is run when the controller is loaded, ie once only - (in production classes aren't reloaded). You need something that happens once per request, is run by an instance of the controller at a particular point in time (after the request has been received by the controller, before the action code is run), so it can't possibly be achieved by class level stuff

Fred