Skip to content

Instantly share code, notes, and snippets.

@pete-a
Last active August 29, 2015 13:56
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 pete-a/8928040 to your computer and use it in GitHub Desktop.
Save pete-a/8928040 to your computer and use it in GitHub Desktop.
Refactor example
# GET /everything
def index
@page = params[:page] ||= 1 # Set as 1 if page number not provided
gon.current_page = @page # Not sure I'm a fan of setting JS variables this way, but will leave for now
@shots = Shot.seen_by(current_user).paginate(page: @page)
@notifications = Notification.unseen_counts(shots: @shots, user: current_user) # Not great, but better
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment