Created
November 27, 2013 18:15
-
-
Save guipdutra/7680472 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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