Class: BookmarkControllerValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/bookmark_controller_validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_controllers_listObject


14
15
16
# File 'app/validators/bookmark_controller_validator.rb', line 14

def self.reset_controllers_list
  @valid_controllers_list = nil
end

.valid_controllers_listObject


8
9
10
11
12
# File 'app/validators/bookmark_controller_validator.rb', line 8

def self.valid_controllers_list
  @valid_controllers_list ||= (["dashboard", "common_parameters"] +
    ActiveRecord::Base.connection.tables.map(&:to_s) +
    Permission.resources.map(&:tableize)).uniq
end

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object


2
3
4
5
6
# File 'app/validators/bookmark_controller_validator.rb', line 2

def validate_each(record, attribute, value)
  unless self.class.valid_controllers_list.include?(value)
    record.errors[attribute] << _("%{value} is not a valid controller") % {:value => value }
  end
end