【问题标题】:Syntax Error while implementing Devise实施设计时出现语法错误
【发布时间】:2013-04-14 03:05:11
【问题描述】:

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

非常感谢任何帮助。

【问题讨论】:

    标签: ruby-on-rails devise


    【解决方案1】:

    ifelseend 不应以&lt;%= 开头,而应以&lt;% 开头,因为不应呈现返回

    【讨论】:

    • 谢谢,这行得通。我纠正的其他错误是拼写错误的“会话”,以及我在模型中使用“餐厅”而不是用户这一事实。
    猜你喜欢
    • 2020-03-02
    • 1970-01-01
    • 2022-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-27
    • 1970-01-01
    • 2013-06-23
    相关资源
    最近更新 更多