Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 链接到不显示任何内容_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 链接到不显示任何内容

Ruby on rails 链接到不显示任何内容,ruby-on-rails,ruby,Ruby On Rails,Ruby,我试图在索引页面中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码 <h1> Listing articles </h1> <% link_to 'New article', new_article_path %> <---- Everything works perfectly except this doesnt show anything <table> <tr> <th

我试图在索引页面中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码

<h1> Listing articles </h1>
<% link_to 'New article', new_article_path %>   <---- Everything works perfectly except this doesnt show anything
<table>
<tr>
 <th>Title</th>
 <th>Textssss</th>
<tr>

<% @articles.each do |article| %>
  <tr>
     <td><%= article.title %> </td> 
     <td><%= article.text %> </td> 
   </tr>
 <% end %>

</table>
我可以从本地主机手动访问文章/新闻,但我认为这不是问题所在。
非常感谢您的帮助。

下面是使用rails link_打印锚定标记到帮助器的正确语法。您忘记了“=”符号

<%= link_to 'New article', new_article_path %> 

ERB模板中的Ruby代码处理

%  enables Ruby code processing for lines beginning with %
<% Ruby code -- inline with output %>
<%= Ruby expression -- replace with result %>
<%# comment -- ignored -- useful in testing %>
% a line of Ruby code -- treated as <% line %> 
%% replaced with % if first thing on a line and % processing is used
<%% or %%> -- replace with <% or %> respectively
%对以%开头的行启用Ruby代码处理
%一行Ruby代码——被视为
%%如果使用了行上的第一件事和%处理,则替换为%
--分别替换为

=
添加到
链接到
然后读一读关于“谢谢你”的书,它澄清了很多事情。。
%  enables Ruby code processing for lines beginning with %
<% Ruby code -- inline with output %>
<%= Ruby expression -- replace with result %>
<%# comment -- ignored -- useful in testing %>
% a line of Ruby code -- treated as <% line %> 
%% replaced with % if first thing on a line and % processing is used
<%% or %%> -- replace with <% or %> respectively