0

我正在尝试在我的 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,期待')'

非常感谢任何帮助。

4

1 回答 1

2

if,else并且不应该以,end开头 , 因为返回不应该被渲染<%=<%

于 2013-04-14T03:07:52.783 回答