From 6460456202bfa5b2f5371fc5f03fd017fc4ff050 Mon Sep 17 00:00:00 2001 From: Aditya Prakash Date: Fri, 12 Feb 2016 23:38:43 +0530 Subject: [PATCH] Update Formtastic and formtastic-bootstrap Previous version of Formtastic was giving following deprecation warning: `#column_for_attribute` will return a null object for non-existent columns in Rails 5. Use #has_attribute? if you need to check for an attribute's existence. Guide followed for upgrade: https://github.com/justinfrench/formtastic/wiki/Upgrading-to-Formtastic-3.1 formtastic-bootstrap is upgraded for compatibility with current Formtastic. --- Gemfile | 2 +- Gemfile.lock | 10 ++++---- config/initializers/formtastic.rb | 40 ++++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 1b6f1b60..90cd87f3 100644 --- a/Gemfile +++ b/Gemfile @@ -52,7 +52,7 @@ gem 'uglifier', '>= 1.3.0' gem 'bootstrap-sass', '~> 3.3.4.1' gem 'autoprefixer-rails' gem 'formtastic-bootstrap' -gem 'formtastic', '~> 2.3.0.rc3' +gem 'formtastic', '~> 3.1.1' gem 'cocoon' # frontend javascripts diff --git a/Gemfile.lock b/Gemfile.lock index 669b82ab..658ba0c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -166,10 +166,10 @@ GEM font-awesome-rails (4.1.0.0) railties (>= 3.2, < 5.0) formatador (0.2.4) - formtastic (2.3.0.rc3) - actionpack (>= 3.0) - formtastic-bootstrap (3.0.0) - formtastic (>= 2.2) + formtastic (3.1.3) + actionpack (>= 3.2.13) + formtastic-bootstrap (3.1.1) + formtastic (>= 3.0) geocoder (1.2.2) globalid (0.3.6) activesupport (>= 4.1.0) @@ -504,7 +504,7 @@ DEPENDENCIES devise_ichain_authenticatable factory_girl_rails font-awesome-rails - formtastic (~> 2.3.0.rc3) + formtastic (~> 3.1.1) formtastic-bootstrap gravtastic guard-rspec (~> 4.2.8) diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb index 4374676b..f21da2e7 100644 --- a/config/initializers/formtastic.rb +++ b/config/initializers/formtastic.rb @@ -66,14 +66,48 @@ Formtastic::FormBuilder.required_string = proc { Formtastic::Util.html_safe(%{&n # specifying that class here. Defaults to Formtastic::FormBuilder. # Formtastic::Helpers::FormHelper.builder = MyCustomBuilder +# All formtastic forms have a class that indicates that they are just that. You +# can change it to any class you want. +# Formtastic::Helpers::FormHelper.default_form_class = 'formtastic' + +# Formtastic will infer a class name from the model, array, string ot symbol you pass to the +# form builder. You can customize the way that class is presented by overriding +# this proc. +# Formtastic::Helpers::FormHelper.default_form_model_class_proc = proc { |model_class_name| model_class_name } + +# Allows to set a custom field_error_proc wrapper. By default this wrapper +# is disabled since `formtastic` already adds an error class to the LI tag +# containing the input. +# Formtastic::Helpers::FormHelper.formtastic_field_error_proc = proc { |html_tag, instance_tag| html_tag } + # You can opt-in to Formtastic's use of the HTML5 `required` attribute on ``, `