我将Spree包含在现有网站中.我正在使用Deface更改spree标题以改为呈现我的网站标题.因此,我使用以下Deface DSL代码
<!-- replace_contents "header[data-hook]" -->
<%= render :partial => "layouts/my_site_header.html.erb" %>
Run Code Online (Sandbox Code Playgroud)
在里面_my_site_header.html.erb我有类似的东西
<ul>
<li><%= link_to "Home", home_path %></li>
<li><%= link_to "Game", game_path %></li>
<li><%= link_to "Community", community_path %></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误
undefined local variable or method `home_path' for #<#<Class:0x8a73c20>:0x8af0e58>
Run Code Online (Sandbox Code Playgroud)
我知道代码在Spree范围内由Deface执行,因此我的网站的url助手是未定义的.我可以使用完整的方法名称来解决这个问题Rails.application.routes.url_helpers.home_path
但是,我真的不想为我的所有链接添加这个.难道没有办法告诉Spree包含我网站的网址助手吗?请帮忙!