在link_to中显示的路径 [英] Paths showing up in link_to

查看:87
本文介绍了在link_to中显示的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚接触过僵尸(railsforzombies.org)的Rails,并且正在尝试构建我的第一个应用程序(博客).

I am new to rails having just completed rails for zombies (railsforzombies.org) and am trying to build my first app (a blog).

我已经搭建了一个基本结构,并进行了一些更改,包括更改路线,添加部分视图以及对视图进行其他改进以及安装Blueprint CSS框架.

I have scaffolded a basic structure and made changes including changing routes adding partials and other improvements to the view as well as installing the Blueprint css framework.

我遇到的问题是,我所有的链接(使用link_to创建)最终都看起来像这样:

The problem I'm having is that all of my links (created with link_to) end up looking like this:

test post(/post/1)

在链接本身之后打印链接路径的位置.但是,我无法复制带有链接路径的文本.

Where the path to the link is printed after the link itself. However, I cannot copy the text with the path to the link.

以防万一,这就是我的route.rb的样子:

In case it helps this is what my routes.rb looks like:

Blog::Application.routes.draw do |map|
  root :to => "Posts#index"
  match '/post/:id' => 'Posts#show', :as => 'show'
  match 'new' => 'Posts#new', :as => 'new_post' 

有帮助吗?

我的link_to调用如下:

my link_to call is as follows:

<em><h2 class = "title"><%=link_to post.title, show_path(post.id) %></h2></em>

该问题可以在此图像中看到.

如果我将其更改为show_url,则该URL也会出现在括号中,而不是路径.

Also if I change to show_url the url appears in the parenthesis as opposed to the path.

推荐答案

问题已解决.

Blueprint CSS弄乱了我的代码.为避免这种情况,请确保在包括Blueprint CSS文件时指定:media选项.您的代码应如下所示:

Blueprint CSS was messing up my code. To avoid this, make sure you specify the :media option when including the Blueprint CSS files. Your code should look something like this:

<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
<%= stylesheet_link_tag 'blueprint/ie'%>

这篇关于在link_to中显示的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆