Search code examples
ruby-on-railsrubygemsactiveadminglobalize

Rails 4 + Globalize + Activeadmin + activeadmin-globalize , activeadmin-translate not working


The block:

form do |f| | f |
    f.translate_inputs of | t |
      t.input : title
      t.input : text
      t.input : locale , as: : hidden
    end
    f.actions
  end

Always shows the last field , I believe the problem is the gem ' activeadmin -translate ' github ' rbatllet / activeadmin -translate ' .

ADMIN/POST.RB

  ActiveAdmin.register Post do    # if you are using Rails 4 or Strong
 Parameters:   permit_params :title, :text, translations_attributes:
 [:locale, :title, :text, :id]


   index do
     # ...
     translation_status
     # ...
     #default_actions   end

   form do |f|
     f.translate_inputs do |t|
       t.input :title
       t.input :text

       t.input :locale, as: :hidden
     end
     f.actions   end end

models/post.rb

 class Post < ActiveRecord::Base

active_admin_translates :title, :text     do
        #validates_presence_of :title
end

    accepts_nested_attributes_for :translations
 end

Solution

  • You need to wrap your code in a inputs do

    try

       form do |f|
        f.inputs "Details" do
         f.translate_inputs do |t|
           t.input :title
           t.input :text
    
           t.input :locale, as: :hidden
         end
       end
         f.actions
       end