0

I am trying to implement devise in my rails app, and getting a Syntax Error in my _header.html.erb partial:

<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>  

The error messages I am getting are:

/Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:10: syntax error, unexpected ')', expecting keyword_then or ';' or '\n' ....append= ( if user_signed_in? );@output_buffer.safe_concat(' ... ^ /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:14: syntax error, unexpected keyword_else ...);@output_buffer.append= ( else );@output_buffer.safe_concat... ... ^ /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:17: syntax error, unexpected keyword_end ...');@output_buffer.append= ( end );@output_buffer.safe_concat... ... ^ /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:23: syntax error, unexpected keyword_ensure, expecting ')' /Users/adnankhan/code/opendeals/app/views/layouts/_header.html.erb:25: syntax error, unexpected keyword_end, expecting ')'

Greatly appreciate any help.

1 Answer 1

2

if, else and end should not start with <%=, but with <%, because the returns are not supposed to be rendered

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this worked. Other mistakes that I corrected were misspelled 'session', and the fact that I had used 'restauranteur' instead of user in my model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.