This file contains 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
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 |
This file contains 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
inputs = %w[ | |
CollectionSelectInput | |
DateTimeInput | |
FileInput | |
GroupedCollectionSelectInput | |
NumericInput | |
PasswordInput | |
RangeInput | |
StringInput | |
TextInput |
This file contains 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
# 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 | |
# |
This file contains 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
#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 |
NewerOlder