我正在尝试在我的rails应用程序中实现设计,并在我的_header.html.erb部分中获取语法错误:
<header class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<%= link_to "OpenDeals", root_path, id: "logo" %>
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Contact", contact_path %></li>
<li>
<%= if user_signed_in? %>
Logged in as <strong><%= current.user.email %></strong>.
<%= link_to 'Edit profile', edit_user_registration_path %>
<%= link_to 'Logout', destroy_user_session_path, method: :delete %>
<%= else %>
<%= link_to 'Sign up', new_user_registration_path %> |
<%= link_to 'Login', new_user_ssession_path %>
<%= end %>
</li>
</ul>
</nav>
</div>
我收到的错误消息是:
/Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:10:语法错误,意外')',期待keyword_then或';'或'\ n' .... append =(if user_signed_in?); @ output_buffer.safe_concat(' ...... ^ /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:14:语法错误,意外的keyword_else ...); @ output_buffer.append =(else); @ output_buffer.safe_concat ... ...... ^ /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:17:语法错误,意外的keyword_end ...'); @ output_buffer.append =(end); @ output_buffer.safe_concat ... ...... ^ /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:23:语法错误,意外的keyword_ensure,期待')' /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:25:语法错误,意外的keyword_end,期待')'
非常感谢任何帮助。
答案 0 :(得分:2)
if
,else
和end
不应该以{{1}}开头,而应该以{{1}}开头,因为不应该呈现回报