Ruby 1.9.3-p194
Rails 3.0.3
我今天遇到了libcrypt错误,经过数小时的故障排除后,我卸载了rvm,ruby和gem。我重新安装了一切,但现在我的应用程序抛出了错误。我没有对我的代码进行任何更改,但在重新安装之前这很好用:
ActionView::Template::Error (/home/username/apps/vits/app/views/layouts/application.html.erb:19: syntax error, unexpected ',', expecting ')'
if (current_user.admin == true, "Admin Menu", adminmenu_path...
/home/username/apps/vits/app/views/layouts/application.html.erb:19: syntax error, unexpected ',', expecting ')'
...er.admin == true, "Admin Menu", adminmenu_path) );@output_bu....
/home/username/apps/vits/app/views/layouts/application.html.erb:22: syntax error, unexpected keyword_do_block, expecting keyword_end
');@output_buffer.append_if_string= flash.each do |name, msg|
/home/username/apps/vits/app/views/layouts/application.html.erb:22: syntax error, unexpected '|', expecting '='
');@output_buffer.append_if_string= flash.each do |name, msg|
/home/username/apps/vits/app/views/layouts/application.html.erb:44: syntax error, unexpected keyword_ensure, expecting $end):
16: <div id="header">
17: <div class="wrap clear">
18: <% if current_user %>
19: <%= link_to "Logout", logout_path %> | <%= link_to "Main Menu", usermenu_path %> | <%= link_to_if (current_user.admin == true, "Admin Menu", adminmenu_path) %>
20: <% end %>
21: </div>
22: <%- flash.each do |name, msg| -%>
app/controllers/user_sessions_controller.rb:29:in `new'
有什么想法吗?对我来说这是一个糟糕的RoR日 提前致谢。 -Katie
编辑添加整个application.html.erb:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><%= h(yield(:title) || "Vendor Invoice Tracking System (VITS)") %></title>
<link rel="stylesheet" href="stylesheets/scaffold.css" type="text/css" media="all" charset="utf-8" />
<%= stylesheet_link_tag 'scaffold' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag "tablesort.js" %>
</head>
<body>
<div id="siteholder">
<div id="header">
<div class="wrap clear">
<% if current_user %>
<%= link_to "Logout", logout_path %> | <%= link_to "Main Menu", usermenu_path %> | <%= link_to_if ((current_user.admin == true, "Admin Menu", adminmenu_path)) %>
<% end %>
</div>
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_#{name}" %></p>
<div class="clear"></div>
<%- end -%>
<% if current_user %>
<div id="content1">
<%= yield %>
</div>
<% else %>
<div id="content">
<div id="content1">
</div>
<%= yield %>
</div>
<% end %>
</div>
</body>
</html>'
答案 0 :(得分:0)
我认为问题在于这一行:
<%= link_to_if (current_user.admin == true, "Admin Menu", adminmenu_path) %>
您不需要== true
,只需:
<%= link_to_if (current_user.admin, "Admin Menu", adminmenu_path) %>
会好的。如果由于某种原因你确实需要检查相等,你需要一对额外的括号,例如:
<%= link_to_if ((current_user.role == "admin"), "Admin Menu", adminmenu_path) %>