【发布时间】:2017-05-06 01:01:55
【问题描述】:
在我的由几个 Rails 引擎组成的 Rails 4.2 应用程序中,需要引擎 itemlized_spendingx 以使用 ajax 调用在引擎 biz_workflowx 中呈现文件。引擎biz_workflowx 包含在itemlized_spendingx 的应用程序控制器中,如下所示:
module ItemlizedSpendingx
class ApplicationController < ::ApplicationController
include BizWorkflowx::WfHelper
end
end
在BizWorkflowx::WfHelper 中,定义了一个动作event_action,它在引擎itemlized_spendingx 的索引视图中被称为带有link_to 的ajax。这是 event_action.js.erb 响应 ajax 调用
$("#newworkflow .modal-content").html('<%= j render(:file => "biz_workflowx/application/event_action.html.erb") %>');
$("#newworkflow").modal();
上面evant_action.js.erb 的目的是使用Bootstrap modal 弹出event_action.html.erb 的视图(event_action.js.erb 和event_action.html.erb 都位于biz_workflowx/app/views/application/ 下的同一个子目录中) .我遇到的问题是render(:file => ..) 会引发template missing 的错误,即使File.file?('biz_workflows/app/views/application/event_action.html.erb) 在ActionView resolver 中返回true。
看起来render 确实很难找到event_action.html.erb,即使File.file? 看到了它。如何让渲染器看到?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 rails-engines