Skip to content

Instantly share code, notes, and snippets.

@Crisfole
Last active August 29, 2015 14:26
Show Gist options
  • Save Crisfole/dc5f558b21b71ed36d10 to your computer and use it in GitHub Desktop.
Save Crisfole/dc5f558b21b71ed36d10 to your computer and use it in GitHub Desktop.
For Jeremy
# In Application Controller:
# Rename your current version of 'current_user' like so:
def _current_user
# Current User Code
end
# Change _current_user to something like this:
def current_user
model = self.class.class_variable_get :@@model rescue nil
param = self.class.class_variable_get :@@param rescue nil
if model
model.find(params[param]).customer
else
_current_user
end
end
# In all subclasses of ApplicationController that require the user to be logged in:
class VideoController < ApplicationController
@@model = Video
@@param = :video_id
# Rest of your code here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment