Combination with SimpleForm's form builder is possible now.

This commit is contained in:
Tibor Nagy 2014-02-21 15:27:18 +01:00
parent d468ccc3db
commit 554441aeb2
2 changed files with 13 additions and 1 deletions

View File

@ -188,6 +188,17 @@ end
<% end %>
```
## Using SimpleForm
If you want to combine form builders of ransack and SimpleForm, just set the RANSACK_FORM_BUILDER environment variable before Rails started, e.g. in ``config/application.rb`` before ``require 'rails/all'`` and of course use ``gem 'simple_form'`` in your ``Gemfile``:
```ruby
require File.expand_path('../boot', __FILE__)
ENV['RANSACK_FORM_BUILDER'] = '::SimpleForm::FormBuilder'
require 'rails/all'
```
## I18n
Take a look at our locale file on ``lib/ransack/locale/en.yml`` to check all available messages. You may also be interested in one of the many translations that are available on:

View File

@ -1,8 +1,9 @@
require 'action_view'
require 'simple_form'
module Ransack
module Helpers
class FormBuilder < ::ActionView::Helpers::FormBuilder
class FormBuilder < ( ENV['RANSACK_FORM_BUILDER'].nil? ? ActionView::Helpers::FormBuilder : ENV['RANSACK_FORM_BUILDER'].constantize )
def label(method, *args, &block)
options = args.extract_options!