得到一个奇怪的语法错误,我之前没有得到,现在我不确定我现在做了什么导致它。
这是我的控制器的样子:
class BlogController < ApplicationController
def cs
@compsci = Compsci.all
end
def personal
@personalb = Personalb.all
end
def archivedBlogs
@compsci = Compsci.all
@personalb = Personalb.all
end
def viewblg (num = 0)
@blog = Compsci.find_by (num)
end
end
我在哪里调用link_to函数(这是我的错误页面上显示的内容):
<div class="panel">
<ul>
<% @compsci.each do |blog| %>
<li><%= link_to "#{blog.title}", viewblog_path (blog.number) %></li>
<% end %>
</ul>
</div>
确切的错误是:
/Users/ebadly-mac/Desktop/apps/blog/app/views/blog/archivedBlogs.html.erb:12:语法错误,意外(arg,期待keyword_do或&#39; {&#39;或&#39;(&#39; ...#{blog.title}&#34;,viewblog_path(blog.number)); @ output_buffer ... ... ^ / Users / ebadly-mac / Desktop / apps /blog/app/views/blog/archivedBlogs.html.erb:20:语法错误,意外的keyword_do_block,期待keyword_end&#39; .freeze; @ personalb.each do | blog | ^ / Users / ebadly-mac / Desktop / apps / blog / app / views / blog / archivedBlogs.html.erb:21:语法错误,意外(arg,期待keyword_do或&#39; {&#39;或&#39;(&#39; ... #{blog.title}&#34;,viewblog_path(blog.number)); @ output_buffer ...... ... ^ /Users/ebadly-mac/Desktop/apps/blog/app/views/blog/archivedBlogs.html .erb:29:语法错误,意外的keyword_ensure,期待输入结束
答案 0 :(得分:1)
您不应在方法名称和括号之间添加空格。