2012-09-29 34 views
0

嗨,我很新的RoR和使用Rails 3.2.8来开发我的应用程序。当我测试我的页面时,URL地址会在所有链接之后自动显示。例如, <%= link_to'Home',root_path%>将在Home(/)之类的浏览器中生成一个视图,但(/)不是可以在页面源中找到的元素。我相信这是因为我处于开发模式?有没有办法关闭此功能?谢谢!如何隐藏浏览器视图在开发模式下的链接后显示的url?

这里是我的代码:

<ul> 
<li><%= link_to "Home", root_path %></li> 
<li><%= link_to "About", about_path %></li> 
<li><%= link_to "Contact", contact_path %></li> 
</ul> 

,这里是产生实际的html代码:

<ul> 
<li><a href="/">Home</a></li> 
<li><a href="/about">About</a></li> 
<li><a href="/contact">Contact</a></li> 
</ul> 

你可以看到这是很正常的......这使我相信这不是一个编码问题。然而,当进入浏览器,它显示为

我想知道在哪里(/ URL)的一部分来自...以及如何摆脱它。

这里是JS文件我用:

<script src="/assets/application.js?body=1" type="text/javascript"></script> 
<script src="/assets/jquery-1.8.0.min.js?body=1" type="text/javascript"></script> 
<script src="/assets/jquery-ui-1.8.23.custom.min.js?body=1" type="text/javascript">  </script> 
<script src="/assets/autocomplete-rails.js?body=1" type="text/javascript"></script> 
<script src="/assets/rails.js?body=1" type="text/javascript"></script> 

Rails的JS是Rails-UJS脚本

+1

更新你的问题与代码示例,并显示与特定链接例子的问题。这将有助于回答你的问题。 – Samiron

+0

感谢Samiron,我添加了一些示例代码...希望我已经明确了我的问题@Samiron – Xiaoli

+0

因此,您的意思是网页显示“关于(/ about)”,而html源代码没有任何内容显示'(/ about )'部分?它的奇怪,然后...可能是你的浏览器设置有问题。所有浏览器都一样吗? – Samiron

回答

1

感谢@Samiron,终于想通了,为什么。蓝图的CSS库中有印刷版本中定义样式表,并具有有代码:

/* 
This has been the source of many questions in the past. This 
snippet of CSS appends the URL of each link within the text. 
The idea is that users printing your webpage will want to know 
the URLs they go to. If you want to remove this functionality, 
comment out this snippet and make sure to re-compress your files. 
*/ 
a:link:after, a:visited:after { 
    content: " (" attr(href) ")"; 
font-size: 90%; 
} 
+0

:)啊...所以css是罪魁祸首。然而,即时通讯想知道关键字的问题。任何人有任何建议? – Samiron

+0

虽然现在我只是用“css链接后显示url”来搜索并获得第一个结果中的东西:) – Samiron

相关问题