Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## application_controller.rb
- class ApplicationController < ActionController::Base
- helper :all # include all helpers, all the time
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
- require 'brazilian-rails'
- layout 'application'
- include AuthenticatedSystem
- before_filter :valida_permissao
- private
- def valida_permissao
- if controller_name == 'sessions' and not action_name == 'index'
- true
- else
- if logged_in?
- acao = Acao.find(:first, :conditions =>
- ["controller_name = ? and action_name = ?",
- controller_name, action_name])
- if current_user.acoes.include? acao
- true
- else
- render :text => "Acesso negado a " + controller_name + ' acao ' +
- action_name + '. Você não tem acesso a esta ação.'
- end
- else
- render :text => "Acesso negado a " + controller_name + ' acao ' +
- action_name + '. Você não está logado'
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment