summaryrefslogtreecommitdiff
path: root/config/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/client_side_validations.rb12
-rw-r--r--config/initializers/customization.rb2
-rw-r--r--config/initializers/error_constants.rb5
-rw-r--r--config/initializers/simple_form_bootstrap.rb12
-rw-r--r--config/initializers/validations.rb4
5 files changed, 21 insertions, 14 deletions
diff --git a/config/initializers/client_side_validations.rb b/config/initializers/client_side_validations.rb
index 252aded..f7a658a 100644
--- a/config/initializers/client_side_validations.rb
+++ b/config/initializers/client_side_validations.rb
@@ -1,9 +1,16 @@
# ClientSideValidations Initializer
-# Uncomment to disable uniqueness validator, possible security issue
-ClientSideValidations::Config.disabled_validators = [:uniqueness]
+# Disabled validators. The uniqueness validator is disabled by default for security issues. Enable it on your own responsibility!
+# ClientSideValidations::Config.disabled_validators = [:uniqueness]
+
+# Uncomment to validate number format with current I18n locale
+# ClientSideValidations::Config.number_format_with_locale = true
# Uncomment the following block if you want each input field to have the validation messages attached.
+#
+# Note: client_side_validation requires the error to be encapsulated within
+# <label for="#{instance.send(:tag_id)}" class="message"></label>
+
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
unless html_tag =~ /^<label/
%{<div class="field_with_errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label></div>}.html_safe
@@ -11,4 +18,3 @@ ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
%{<div class="field_with_errors">#{html_tag}</div>}.html_safe
end
end
-
diff --git a/config/initializers/customization.rb b/config/initializers/customization.rb
index aaa2939..9f537e9 100644
--- a/config/initializers/customization.rb
+++ b/config/initializers/customization.rb
@@ -26,7 +26,7 @@ Rails.application.config.assets.paths.unshift "#{customization_directory}/styles
#
# Copy files to public
#
-if !defined?(RAKE) && Dir.exists?("#{customization_directory}/public")
+if !defined?(RAKE) && Dir.exist?("#{customization_directory}/public")
require 'fileutils'
FileUtils.cp_r("#{customization_directory}/public/.", "#{Rails.root}/public", :preserve => true)
end
diff --git a/config/initializers/error_constants.rb b/config/initializers/error_constants.rb
index fdd3624..bf2dad4 100644
--- a/config/initializers/error_constants.rb
+++ b/config/initializers/error_constants.rb
@@ -1,3 +1,8 @@
require 'ruby-srp'
WRONG_PASSWORD = SRP::WrongPassword
+
+# In case we use a different ORM at some point
+VALIDATION_FAILED = CouchRest::Model::Errors::Validations
+RECORD_NOT_FOUND = CouchRest::Model::DocumentNotFound
+RESOURCE_NOT_FOUDN = CouchRest::NotFound
diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb
index c949f5e..720174f 100644
--- a/config/initializers/simple_form_bootstrap.rb
+++ b/config/initializers/simple_form_bootstrap.rb
@@ -1,17 +1,17 @@
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
- config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
+ config.wrappers :bootstrap, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b|
b.use :html5
b.use :placeholder
- b.use :label
- b.wrapper :tag => 'div', :class => 'controls' do |ba|
+ b.use :label, :class => 'col-sm-2'
+ b.wrapper :tag => 'div', :class => 'col-sm-10' do |ba|
ba.use :input
ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
end
end
- config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
+ config.wrappers :prepend, :tag => 'div', :class => "form-group", :error_class => 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
@@ -24,7 +24,7 @@ SimpleForm.setup do |config|
end
end
- config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
+ config.wrappers :append, :tag => 'div', :class => "form-group", :error_class => 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
@@ -38,7 +38,7 @@ SimpleForm.setup do |config|
end
#
- # when you don't want any bootstrap "control-group" or "controls" wrappers.
+ # when you don't want any bootstrap "form-group" or "controls" wrappers.
#
config.wrappers :none, :tag => 'div', :error_class => 'error' do |b|
b.use :html5
diff --git a/config/initializers/validations.rb b/config/initializers/validations.rb
deleted file mode 100644
index e8acfbe..0000000
--- a/config/initializers/validations.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# In case we use a different ORM at some point
-VALIDATION_FAILED = CouchRest::Model::Errors::Validations
-RECORD_NOT_FOUND = CouchRest::Model::DocumentNotFound
-RESOURCE_NOT_FOUND = RestClient::ResourceNotFound