2012-03-14 4 views
0

: 일부 코드는 다음과 같이 작동하지 :입력이 배열에서 작동하지 않습니까? active_admin에서

form do |f| 
f.inputs "title" do 
    %w(AreaGroupId DescriptionFlags Dispel Mechanic modalNextSpell).each do |ele| 
    f.input ele 
    end 
    end 
end 

나는이 같은 다른 형식을 쓸 때 :

form do |f| 
    f.inputs "title" do 
    f.input AreaGroupId 
    f.input DescriptionFlags 
    f.input Dispel 
    f.input Mechanic 
    f.input modalNextSpell 
    end 
end 

이 때문에이

이유를 실행할 수 있습니까? 뭔가 잘못 ?

답변

1

Formtastic이 작동하는 방식으로 f.inputs에 주어진 블록이 마지막 입력을 반환해야하기 때문입니다. 빠른 수정을 원할 경우 다음을 시도하십시오.

form do |f| 
f.inputs "title" do 
    %w(AreaGroupId DescriptionFlags Dispel Mechanic modalNextSpell).map do |ele| 
    f.input ele 
    end.last 
    end 
end 
+1

예. 고쳐 주셔서 감사합니다! – lioooo

관련 문제