Skip to content

Instantly share code, notes, and snippets.

@StephenRoos
StephenRoos / application_controller.rb
Last active February 26, 2016 19:42
Subdomain Logic for TMJ
class ApplicationController < ActionController::Base
before_filter :enforce_government
helper_method :current_government
def enforce_government
if current_user
# if the current user belongs to a government, then
# make sure that they are using that government's subdomain.
# otherwise, make sure they are using the default subdomain...
if current_user.government.present?
@StephenRoos
StephenRoos / divisions_controller.rb
Created April 12, 2016 21:28
Proposed updates to YNS API
class Api::V1::DivisionsController < Api::V1Controller
def index
options = pagination_options
divisions = Division.search(options)
render_paginated(divisions, options[:page], options[:per_page], divisions.total_pages, divisions.total_count)
end
def show
render_success(current_division)

Overview

Our app relies entirely on the current_user helper method (found in our ApplicationController) to retrieve the User object associated with the currently logged-in user (if any). You guys are using the devise gem for authentication, but you still have a current_user helper method which is made available to ApplicationController (and all subclasses).

Normally, the current_user method looks something like this:

def current_user
  # do some magic to get the user id from the (encrypted) session cookie…
 user_id = get_user_id_from_session

Setting up the Secrets Submodule

First, cd into your career_arc repo and pull the latest changes...

> cd ~/repos/career_arc
> git pull

Next, initalize the git submodules feature: