如何从表单对象(@ banner.name)中读取记录参数?
= simple_form_for @banner |f|
= f.name
...
= f.simple_fields_for :params do |o|
= o.name ????
= o.created_at ????
答案 0 :(得分:2)
试试这种方式
= simple_form_for @banner |f|
= f.input :name
...
= f.simple_fields_for :params do |o|
= o.input :name
= o.input :created_at, :as => :date
但我不确定为什么你需要输入created_at。无论如何,带有示例的文档位于their Github page
只显示值object
方法
= simple_form_for @banner |f|
= f.object.name
...
= f.simple_fields_for :params do |o|
= o.object.name
= o.object.created_at.strftime('%x %X') # strftime just to format