Skip to content

Instantly share code, notes, and snippets.

@guipdutra
Created November 27, 2013 17:09
Show Gist options
  • Select an option

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

Select an option

Save guipdutra/7679356 to your computer and use it in GitHub Desktop.
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