Skip to content

Instantly share code, notes, and snippets.

@guipdutra
Created November 27, 2013 18:15
Show Gist options
  • Select an option

  • Save guipdutra/7680472 to your computer and use it in GitHub Desktop.

Select an option

Save guipdutra/7680472 to your computer and use it in GitHub Desktop.
class HomeController < ApplicationController
def index
if current_user and current_user.current_organization
if current_user_is_cells_leader
redirect_to organization_cell_weekly_reports_not_sent_last_week_index_path(current_user.current_organization)
else
redirect_to organization_path(current_user.current_organization)
end
elsif current_user
redirect_to profile_path
else
render :layout => false
end
end
private
def current_user_is_cells_leader
Cell.where(:leader_member => current_user_organization_connection).first
end
def current_user_organization_connection
@current_user_organization_connection ||= UserOrganizationConnection.where(:user_id => current_user, :organization => current_user.current_organization).first!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment