添加 show.rjs 会导致 show.haml 页面出现错误
我有一个控制器,我希望能够响应 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其重命名为
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.