[英]Rails:how to show name instead of ID or Address in has_many relation in active_admin?
[英]How do I change title and name button in f.has_many ? active_admin on rails
我想在f.has_many
更改标题和名称按钮。
我在rails上使用active_admin
这是我的代码:
f.has_many :gallery_apps do |i|
i.input :img,:label => "New Screen Shot" ,:as => :file ,:multipart => true
end
现在Title显示“Gallery app”,名称按钮是“Add New Gallery App”
如何编辑代码?
我认为这可能对你有用
f.has_many :gallery_apps, heading: "Gallery app" ,new_record: "Add New Gallery App" do |i|
i.input :img,:label => "New Screen Shot" ,:as => :file ,:multipart => true
end
您可以通过区域设置控制显示的模型名称。
例如,在/config/locales/en.yml中:
en:
activerecord:
models:
gallery_app:
one: "Screen Shot"
other: "Screen Shots"
看一下simple_form gem https://github.com/plataformatec/simple_form 。 这是表格的一种非常好的方式。 您可以通过添加来更改标签
label: 'Your Label'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.