Sha256: b9b780c79a1cf07e60c891f067e645545697fa51428b792180147feaee881aa2

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

Census.configure do |config|
  # To restrict access to the census admin UI, specify a code snippet that
  # evaluates to true for anyone who should have access. By default, everyone
  # has access to the admin UI.
  #
  # config.admin_role = 'current_user.admin?'
end

#
# Define data types. All data is stored in the database as strings, and you can
# provide procs that will be used to convert from the stored strings to any data
# type you need.
#
# :sql_transform - should return a SQL fragment that will be used for comparing
#                  data when doing search queries
# :format_data   - is used to convert data from its string representation
# :validate_data - is used to validate form field submissions, and should return
#                  nil if the data is valid and an error message if it is invalid
#
Census::DataType.define("String")

Census::DataType.define(
  "Number",
  :sql_transform  => lambda {|column_name| "CAST(#{column_name} AS SIGNED INTEGER)"},
  :format_data    => lambda {|data| data.to_i unless data.blank? },
  :validate_data  => lambda {|data| "must be a number" unless data =~ /^\d*$/}
)

Version data entries

13 entries across 7 versions & 1 rubygems

Version Path
census-0.5.2 generators/census/templates/census.rb
census-0.5.2 test/rails_root/config/initializers/census.rb
census-0.5.0 test/rails_root/config/initializers/census.rb
census-0.5.0 generators/census/templates/census.rb
census-0.4.4 test/rails_root/config/initializers/census.rb
census-0.4.4 generators/census/templates/census.rb
census-0.4.3 test/rails_root/config/initializers/census.rb
census-0.4.3 generators/census/templates/census.rb
census-0.4.2 test/rails_root/config/initializers/census.rb
census-0.4.2 generators/census/templates/census.rb
census-0.4.1 test/rails_root/config/initializers/census.rb
census-0.4.1 generators/census/templates/census.rb
census-0.4.0 generators/census/templates/census.rb