2014-03-12 07:42:11 -06:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
# For APIs, you may want to use :null_session instead.
|
2016-11-09 15:54:05 -07:00
|
|
|
protect_from_forgery with: :null_session
|
2018-06-11 15:13:29 -06:00
|
|
|
|
|
|
|
def current_device
|
|
|
|
if @current_device
|
|
|
|
@current_device
|
|
|
|
else
|
|
|
|
@current_device = (current_user.try(:device) || no_device)
|
2019-07-09 19:40:31 -06:00
|
|
|
# Mutable state eww
|
|
|
|
Device.send(:current=, @current_device)
|
2018-06-11 15:13:29 -06:00
|
|
|
@current_device
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_device_id
|
|
|
|
"device_#{current_device.try(:id) || 0}"
|
|
|
|
end
|
2014-03-12 07:42:11 -06:00
|
|
|
end
|