添加 show.rjs 会导致 show.haml 页面出现错误

发布于 2024-10-12 08:28:58 字数 574 浏览 9 评论 0原文

我有一个控制器,我希望能够响应 html 或 js 请求。 目前,我有一个 HAML 页面,显示有关文档的信息。只需将 show.rjs 文件添加到views/documents 文件夹中,我就会开始出现错误。

这是呈现的内容:

try { } catch (e) { alert('RJS error:\n\n' + e.toString()); alert(''); throw e }

这是我的控制器:

def show
    @document = Document.find(params[:id])
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @document }
      format.js
    end
end

这是 show.rjs:

logger.debug "what the heck!"

任何人都知道为什么这可能不起作用?

I have a controller that I want to be able to respond to html or to js requests.
Currently, I have a HAML page that shows information about a document. Simply by adding a show.rjs file to the views/documents folder, I start getting errors.

Here is what renders:

try { } catch (e) { alert('RJS error:\n\n' + e.toString()); alert(''); throw e }

Here is my controller:

def show
    @document = Document.find(params[:id])
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @document }
      format.js
    end
end

here is show.rjs:

logger.debug "what the heck!"

Anyone have any idea why this might not be working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回心转意 2024-10-19 08:28:58

将其重命名为 show.js.erb

将内容更改为 <% logger.debug "what the heck!"%>

我认为最新的就足够了。

Rename it show.js.erb

Change your content to <% logger.debug "what the heck!"%>

I think the latest is enough though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文