Skip to content

Instantly share code, notes, and snippets.

@danott
Last active December 14, 2015 06:29
Show Gist options
  • Save danott/5042731 to your computer and use it in GitHub Desktop.
Save danott/5042731 to your computer and use it in GitHub Desktop.
An idea on writing readable controller code.
# ActionController#action arguments as documentation.
#
# I've been writing controller#action method definitions with inline arguments
# on a recent project. I started taking this approach to provide an at-a-glance
# "documentation" on what inputs an action is expecting to interact with in
# the course of it's execution.
class IdeaController < ActionController::Base
def take_action(email = params[:email], password = params[:password])
# Take some action with email and password
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment