0

您好,我正在尝试在 ajax 调用中将 html 部分检索为单个字符串。我正在使用 public_activity gem。因为我没有找到render_activity从控制器调用 partial() 的方法。我尝试使用以下代码,但我收到一条错误消息,提示我不能进行多个渲染调用。关于如何实现我想要的任何想法?

    @new_feeds.each_with_index do |new_feed|
      if new_feed.trackable_type == "CompanyDocument" 
        if new_feed.key == "company_document.create"
          html = render partial: 'public_activity/company_document/create', :locals => { :activity => new_feed }
        elsif new_feed.key == "company_document.update"
          html = render partial: 'public_activity/company_document/update', :locals => { :activity => new_feed }
        end
      elsif new_feed.trackable_type == "CompanyVideo" 
        if new_feed.key == "company_video.create"
          html = render partial: 'public_activity/company_video/create', :locals => { :activity => new_feed }
        elsif new_feed.key == "company_video.update"
          html = render partial: 'public_activity/company_video/update', :locals => { :activity => new_feed }
        end
      end
   end
4

1 回答 1

2

将所有出现的 替换renderrender_to_string

于 2014-06-26T17:11:07.297 回答