Rails 4 + 全球化 + Activeadmin + activeadmin-globalize ,activeadmin-translate 不工作
Rails 4 + Globalize + Activeadmin + activeadmin-globalize , activeadmin-translate not working
块:
form do |f| | f |
f.translate_inputs of | t |
t.input : title
t.input : text
t.input : locale , as: : hidden
end
f.actions
end
总是显示最后一个字段,我认为问题出在 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
我认为您正在使用这个 gem:https://github.com/unmantained-activeadmin-plugins/activeadmin-globalize。请注意,在 gem 的自述文件中指出:
Sorry, but I no longer work on ActiveAdmin often enough to justify
mantaining this gem.
您需要将代码包装在 inputs do
尝试
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
块:
form do |f| | f |
f.translate_inputs of | t |
t.input : title
t.input : text
t.input : locale , as: : hidden
end
f.actions
end
总是显示最后一个字段,我认为问题出在 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
我认为您正在使用这个 gem:https://github.com/unmantained-activeadmin-plugins/activeadmin-globalize。请注意,在 gem 的自述文件中指出:
Sorry, but I no longer work on ActiveAdmin often enough to justify mantaining this gem.
您需要将代码包装在 inputs do
尝试
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