2
나는 작업이 있습니다. 다른 필드 표시는 객체 매개 변수에 따라 다릅니다.ActiveAdmin에 표시 할 조건을 추가하는 방법
예를 들어 현재 양식의 message_type이 'custom'인 경우 예 : 하나가 아닌 경우 입력을 표시하고 다른 하나는 표시합니다. 여기
지금 작동하는 무슨 코드입니다 : 이form do |f|
if f.object.new_record? || f.object.message_type == 'custom'
f.inputs do
f.input :custom_topic
f.input :custom_content, as: :text
end
f.actions
end
end
show do
attributes_table do
if :message_type == 'custom'
row :message_type
row(:topic) { |object| object.notification_data['topic'] }
row(:content) { |object| object.notification_data['content'] }
else
row :message_type
row :notification_data
end
end
end
이 나에게 보여줍니다
message_type = {기호}
및 동의거야)
하지만 어떻게 현재 객체의 message_type 값을 확인 하시겠습니까? 울부 짖는 소리
내 모든 코드는 : 방법은 일반적으로 당신이 관리하는 모델의 이름을 따서 명명로 show
블록에서
ActiveAdmin.register Notification do
belongs_to :case, finder: :find_by_slug
permit_params :message_type, :custom_topic, :custom_content, :notification_data
form do |f|
if f.object.new_record? || f.object.message_type == 'custom'
f.inputs do
f.input :custom_topic
f.input :custom_content, as: :text
end
f.actions
end
end
show do
attributes_table do
if :message_type == 'custom'
row :message_type
row(:topic) { |object| object.notification_data['topic'] }
row(:content) { |object| object.notification_data['content'] }
else
row :message_type
row :notification_data
end
end
end
config.filters = false
end
감사합니다. 너는 내 목숨을 구했어) –