activeadmin:帮助器中的link_to不会出现在视图中

时间:2015-11-22 19:33:36

标签: ruby-on-rails activeadmin

我有一个帮助器,我用它在ActiveAdmin表单中动态渲染新字段。

module ApplicationHelper
    def link_to_add_property_fields(name, f, association)
        new_object = Item::Property.new({item_attribute_id: '', value: ''})
        id = new_object.object_id

        fields = f.semantic_fields_for(association, new_object, child_index: id) do |builder|
            render(association.to_s.singularize + "_fields", f: builder)
        end

        fields = fields.to_s.html_safe

        link_to(name, '#', class: 'add_property_fields', data: {id: id, fields: fields.gsub("\n", "")})
    end
end

link_to未在页面上呈现外,一切正常。 我试图使用render html:渲染它,但无济于事。 还有其他选择吗?

1 个答案:

答案 0 :(得分:2)

通过抛出模板解决了这个问题。

import pandas as pd

def importtest():
    ilist = pd.read_csv('Z:/fakepath/ID.csv')
    for i in range(0, len(ilist['ID'].unique())):
        tempID = ilist['ID'].unique()[i]
        exec("variable%s = pd.read_csv('%s')" % (
            str(tempID), 'Z:/fakepath/'+str(tempID)+'.csv'), globals())
        i = i + 1