Skip to content

Instantly share code, notes, and snippets.

View joseh-henrique's full-sized avatar

Joseh-Henrique joseh-henrique

View GitHub Profile
@joseh-henrique
joseh-henrique / searching.rb
Created October 7, 2015 13:53 — forked from xdougx/searching.rb
A intenção era só simplificar e ganhar todos os métodos sem precisar fazer muito, é muito simples fazer em uma classe desprendida do ActiveRecord
module Searchable
included do
scope :gender, ->(gender) { where(:gender => gender) }
scope :birth_on, ->(date) { where(:birthdate =>date) }
scope :birth_before_than, ->(date) { where("#{quoted_table_name}.birthdate < ?", date) }
scope :birth_after_than, ->(date) { where("#{quoted_table_name}.birthdate > ?", date) }
scope :profile, ->(profile){ where(:profile => profile) }
end
module ClassMethods
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
@joseh-henrique
joseh-henrique / activeadmin-cancan.rb
Created November 12, 2012 11:00 — forked from mrichie/activeadmin-cancan.rb
Deep integration of CanCan into ActiveAdmin
# blog post:
# Before using this initializer, you must set up Cancan. First, add the gem to your Gemfile:
#
# gem 'cancan'
#
# Next, generate and edit an Ability class:
#
# rails generate cancan:ability
#
@joseh-henrique
joseh-henrique / ability.rb
Created September 4, 2012 19:06 — forked from andrerpbts/ability.rb
Menus SGO
#encoding: utf-8
class Ability
include CanCan::Ability
def initialize(user)
user.perfis.each do |perfil|
perfil.permissoes_perfis.each do |permissao|
can permissao.acao.to_sym, Recurso.por_tipo(permissao.recurso, permissao.tipo)
end
end