I am developing an application with Ruby on Rails (4.1) and I use the Globalize gem (version 4.0.1) to store various translations of my data. The problem is that when I use the "globalize_fields_for" method of simple_form in order to generate the form fields for the various locales, I get the following error:
undefined method `globalize_fields_for' for #<SimpleForm::FormBuilder:0x00000106824928>
Here is my view (haml):
h3.title New Static Page
%hr
= simple_form_for [:admin, @static_page] do |f|
%dl.tabs{ "data-tab" => "" }
- @locales.each_with_index do |lang, index|
- klass = index == 0 ? 'active' : ''
%dd{ class: klass }= link_to t("admin.languages.#{lang}"), "#panel2-#{index + 1}", class: "#{lang} flag"
.tabs-content
- @locales.each_with_index do |lang, index|
- klass2 = index == 0 ? 'active' : ''
.content{ class: klass2, id: "panel2-#{index + 1}"}
= f.globalize_fields_for lang.to_sym do |g|
= g.input :title, label: "Title"
= g.cktext_area :body, rows: 15, class: 'ckeditor'
= f.button :submit, t('admin.buttons.submit'), class: 'new-submission'
the "@locales" variable has my locales (['el', 'en', 'ru'].
My model is as follows:
class StaticPage < ActiveRecord::Base
extend FriendlyId
friendly_id :title, use: [:slugged, :history]
# Validations
validates :title, presence: true, length: { maximum: 100 }
validates_presence_of :body
# Associations
translates :title, :body
has_many :translations
accepts_nested_attributes_for :translations
end
If I use the "simple_fields_for" helper, then I get an error that says that I have undefined attribute "el" (or any other of the locales that I have created) which is valid as there is none declared in my model.
I am stuck for a couple of hours on this so any help/suggestion will be appreciated :)