我正在尝试让我的rails应用程序生成一个没有文本和自定义内容的链接。我目前正在做这个
<%= link_to '', {:controller => :project, :action => :show}, {:id => project.id, :class => "projects"} do %>
<div class="image-container">
<%= image_tag project.images[0].image.url, :title => project.title %>
</div>
<p>
<span class="title">
<%= project.title %>
</span>
<span class="summary">
<%= project.summary %>
</span>
</p>
<% end %>
哪个生成此代码
<a action="show" controller="project" href>
<div class="image-container">
<img alt="House 2" src="/uploads/project_image/image/1/house-2.jpg" title="Ygfaweg">
</div>
<p>
<span class="title">
</span>
<span class="summary">
</span>
</p>
</a>
链接不正确,缺少大量数据,不知道为什么?
答案 0 :(得分:0)
''
方法移除link_to
。:controller
方法中的link_to
更改为projects
:id => project.id, :class => "projects"
所以,重构第一行:
<%= link_to {:controller => :projects, :action => :show}, :id => project.id, :class => "projects" do %>
答案 1 :(得分:0)
我没有就这个问题得出一个纯粹的结论。我最终这样做了,效果很好。
<html>
<head>
<title>NueroEdge | Powered By Anazro</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.dropotron.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/skel-layers.min.js"></script>
<script src="js/init.js"></script>
<script src="js/footage.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
</head>
<body class="homepage">
<!-- Header Wrapper -->
<div class="wrapper style1">
<!-- Header -->
<div id="header">
<div class="container">
<!-- Logo -->
<h1><a href="index.html" img src="images/NueroEdgeText.png" alt="NueroEdge" style="width:105px;height:55px">
<!-- Nav -->
<nav id="nav">
<ul>
<img src="images/NueroEdgeText.png" alt="NueroEdge" style="width:105px;height:55px">
<li class="active">
<a href="index.html">Home</a>
<ul>
<li><a href="aboutus.html">About Us</a></li>
<li><a href="contactus.html">Contact Us</a></li>
</li>
</ul>
<li><a href="https://www.anazro.com/">Anazro Store</a></li>
<li><a href="left-sidebar.html">Application</a></li>
<li>
<a href="">Roster</a>
<ul>
<li><a href="#">Call Of Duty</a></li>
<li><a href="#">Streaming</a></li>
<li><a href="#">Staff</a></li>
</ul>
</li>
<li>
<a href="">More...</a>
<ul>
<!--<li><a href="#">Lorem ipsum dolor</a></li>-->
<li>
<a href="">LeaderBoard</a>
<ul>
<li>
<a href="">Ryan Tarson</a>
<ul>
<li><a href="#"><img src="images/ryantarson.png" alt="TECGaming" style="width:50px;height:50px">Ryan Tarson AKA: TECGaming</a></li>
<li><Strong>Age:</Strong> 17</li>
<li><Strong>Current Favourite Game:</Strong> Grand Theft Auto V PC</li>
<li>I am Ryan Loves video games, computers and coding specifically Java, He plays really all types of</li>
<li>games from a wide range and is willing to play any games from any genre to. He has a great and</li>
<li>fun personality which would keep you hooked on his stream like it was a drug. Ryan is the type</li>
<li>of streamer that is willing to do anything to keep his fans entertained. He has streamed before </li>
<li>but never streamed seriously but planning to do so. I am the website Programmer as well!</li>
<li>Click the links below and become apart of my life!</li>
<div class="row double">
<li><a href="https://twitter.com/TECGaming360" class="button">Twitter</a></li>
<li><a href="https://www.youtube.com/user/TECGaming360" class="button">YouTube</a></li>
</div>
</ul>
</li>
<br>
<li>
<a href="">Kavin I.</a>
<ul>
<li><a href="#"><img src="images/profile.jpeg" alt="NueroEdge" style="width:50px;height:50px">Kavin I. AKA: KaVn Ne</a></li>
<li><Strong>Age:</Strong> 16</li>
<li><Strong>Current Favourite Game:</Strong> Advanced Warefare</li>
<li>Kavin I. AKA KaVn Ne is Co-Founder along Side Ryan Tarson, Kavin loves video games</li>
<li>mostly Call of Duty because that’s all he ever plays. He mostly plays all he</li>
<li>ever plays. He mostly plays competitively and will stream singles matches or just</li>
<li>random hangouts with fans but he would play other games if Call of Duty is down</li>
<li> or someone requests something different. Kavin loves computers and any type of</li>
<li>electronics for some odd reason. Kavin has a unique personality and which could</li>
<li>make you become addicted to watching him play video games BEWARE!</li>
<div class="row double">
<li><a href="https://twitter.com/KaVn_Ne" class="button">Twitter</a></li>
<li><a href="https://www.youtube.com/channel/UC6RGgeacGovnYZko5ZFAZjg" class="button">YouTube</a></li>
</div>
</ul>
</li>
<br>
<li>
<a href="">Nick Marchitelli</a>
<ul>
<li><a href="#"><img src="images/Praise.jpg" alt="Praise" style="width:50px;height:50px">Nick Marchitelli AKA: Praise</a></li>
<li><Strong>Age:</Strong> 16</li>
<li><Strong>Current Favourite Game:</Strong> N/A</li>
<li>Player and Captain for NueroEdge Call of Duty eSports Team.</li>
<br>
<li>Usually plays the supportive role on the team and also calls most of the shots and plays since he</li>
<li>is captain but everyone has their time to shine if no plays aren’t working.</li>
<li>Hybrid player AR and SMG role.</li>
<li>Currently in 16th place In North America for win on GameBattles</li>
<li>Been Playing Competitive Since COD Ghost</li>
<li>Won a few Online Twitter Tournaments with his team.</li>
<li><Strong>Previous affiliations:</strong></li>
<li>✦<Strong> Spectra eSports</Strong></li>
<li>✦<Strong> Livid eSports</Strong></li>
<div class="row double">
<li><a href="https://twitter.com/Praise_Ne" class="button">Twitter</a></li>
<li><a href="umggaming.com/livid-praise " class="button">UMG Gaming</a></li>
</div>
</ul>
</li>
<br>
<li>
<a href="">Luke Pondillo</a>
<ul>
<li><a href="#"><img src="images/profile.jpeg" alt="nueroedge" style="width:50px;height:50px">Luke Pondillo AKA: Flusso</a></li>
<li><Strong>Age:</Strong> 16</li>
<li><Strong>Current Favourite Game:</Strong> N/A</li>
<li>Player for NueroEdge Call of Duty eSports Team.</li>
<br>
<li>Usually plays the Objective role on the team he nice on the sticks with his spot on AR skills but</li>
<li>also can use a SMG, which makes him a hybrid player. The kind of player who can step up when </li>
<li>the team needs it.</li>
<li>Been Playing Competitive Since COD Ghost.</li>
<li>Won a few Online Twitter Tournaments with his team.</li>
<li><Strong>Previous affiliations:</strong></li>
<li>✦<Strong> Spectra eSports</Strong></li>
<li>✦<Strong> Livid eSports</Strong></li>
<div class="row double">
<li><a href="https://twitter.com/FlussoNe" class="button">Twitter</a></li>
<li><a href="#" class="button">YouTube</a></li>
</div>
</ul>
</li>
<br>
<li>
<a href="">Joseph Balasico</a>
<ul>
<li><a href="#"><img src="images/palm.jpeg" alt="palm" style="width:50px;height:50px">Joseph Balasico AKA: Palm</a></li>
<li><Strong>Age:</Strong> 15</li>
<li><Strong>Current Favourite Game:</Strong> N/A</li>
<li>Player for NueroEdge Call of Duty eSports Team.</li>
<br>
<li>Usually plays the Slayer role on the team he is known to be getting 30+ kills in every respawn</li>
<li>and He is a hybrid player where he can use an AR and a SMG. His slaying skill itself helps guide </li>
<li>his team to victory.</li>
<li>Like to use an AR and SMG which makes him a Hybrid Player</li>
<li>Been Playing Competitive COD since COD Ghost.</li>
<li>Won a few Online Twitter Tournaments with his team.</li>
<li><Strong>Previous affiliations:</strong></li>
<li>✦<Strong> Spectra eSports</Strong></li>
<li>✦<Strong> Livid eSports</Strong></li>
<div class="row double">
<li><a href="https://twitter.com/LiviD_Palm" class="button">Twitter</a></li>
<li><a href="#" class="button">YouTube</a></li>
</div>
</li>
</ul>
</li>
</ul>
<!--<li><a href="#">Veroeros feugiat</a></li>-->
</ul>
</li>
</nav>
</div>
</div>
<!-- Banner -->
<<div id="banner">
<section class="container">
<h2>NueroEdge</h2>
<span>NueroEdge Outstanding performance at MLG Event</span>
<p>Looking for more fantastic players for our team!</P>
<a href="application.html" class="button alt">Sign Up</a>
</section>
</div>
</div>
为每个人欢呼!
答案 2 :(得分:0)
尝试这样做:
<%= link_to ({:controller => :project, :action => :show,:id => project.id}, {:class => "projects"}) do %>
<div class="image-container">
<%= image_tag project.images[0].image.url, :title => project.title %>
</div>
<p>
<span class="title">
<%= project.title %>
</span>
<span class="summary">
<%= project.summary %>
</span>
</p>
<% end %>
希望这会对你有所帮助。
答案 3 :(得分:0)
只需从link_to中删除空白字符串即可。
<%= link_to {:controller => :project, :action => :show}, {:id => project.id, :class => "projects"} do %>
<div class="image-container">
<%= image_tag project.images[0].image.url, :title => project.title %>
</div>
<p>
<span class="title">
<%= project.title %>
</span>
<span class="summary">
<%= project.summary %>
</span>
</p>
<% end %>