ruby-on-rails – Rails纯文本模板
发布时间:2020-12-17 04:19:29 所属栏目:百科 来源:网络整理
导读:我想在Rails中将ERB模板呈现为纯文本.理想情况下,我可以做这样的事情: 应用程序/视图/测试/ test.txt.erb Test%= @test % 当我尝试时,Rails抱怨以下错误: ActionView::MissingTemplate (Missing template test/test,application/test with {:locale=[:en],
我想在Rails中将ERB模板呈现为纯文本.理想情况下,我可以做这样的事情:
应用程序/视图/测试/ test.txt.erb Test <%= @test %> 当我尝试时,Rails抱怨以下错误: ActionView::MissingTemplate (Missing template test/test,application/test with {:locale=>[:en],:formats=>[:html],:variants=>[],:handlers=>[:erb,:builder,:raw,:ruby,:coffee]}. Searched in: * "/Users/landonschropp/Development/test/app/views" ): 解决方法
最简单的方法是采取行动:
render '/test/test.text.erb',layout: false,content_type: 'text/plain' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |