Created
November 27, 2013 17:09
-
-
Save guipdutra/7679356 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 Organizations::CellWeeklyReportsNotSent::CellWeeklyReportsNotSentIndexController < ApplicationController | |
| #método repetido em vários controllers | |
| def current_user_organization_connection | |
| @current_user_organization_connection ||= UserOrganizationConnection.where(:user_id => current_user, :organization_id => params[:organization_id]).first! | |
| end | |
| end | |
| class ApplicationController < ActionController::Base | |
| #caso o métododo repetido for uma permissão, recomendo que extrai para um módulo para ficar mais organizado. | |
| include CellsPermission | |
| def current_user_organization_connection | |
| @current_user_organization_connection ||= UserOrganizationConnection.where(:user_id => current_user, :organization_id => params[:organization_id]).first! | |
| end | |
| end | |
| module CellsPermission | |
| #permissions.... | |
| end | |
| class Organizations::CellWeeklyReportsNotSent::CellWeeklyReportsNotSentIndexController < ApplicationController | |
| #utilização da permissao | |
| before_filer :permission | |
| #utilização do método no application controller | |
| def any_method | |
| do_somethign_with(current_user_organization_connection) | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment