Rails的新手并收到此错误:
SyntaxError in RestaurantsController#index
/home/action/workspace/yelp_demo/app/views/layouts/_navbar.html.erb:40: syntax error, unexpected keyword_ensure, expecting end-of-input
但错误,我想是在这里:
app/views/layouts/application.html.erb:12:in `_app_views_layouts_application_html_erb___1775868341330703453_36033920'
所以这是application.html.erb代码:
<!DOCTYPE html>
<html>
<head>
<title>Yelpdemo</title>
<%= render 'layouts/bootstrap' %>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= render 'layouts/navbar' %>
<div class="container-fluid">
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div class="alert alert-<%= name == "notice" ? "success" : "danger" %> alert-dismissable">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
</div>
<% end %>
<% end %>
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
这是我的_navbar.html.erb:
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to "Yelpdemo", root_path, class: "navbar-brand" %>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><%= link_to "About", pages_about_path %></li>
<li><%= link_to "Contact", pages_contact_path %></li>
</ul>
<%= form_tag search_restaurants_path, method: :get, class: "navbar-form navbar-left" do %>
<p>
<%= text_field_tag :search, params[:search], class: "form-control" %>
<%= submit_tag "Search", name: nil, class: "btn btn-default" %>
</p>
<% end %>
<% end %>
<ul class="nav navbar-nav navbar-right">
<% if user_signed_in? %>
<li><%= link_to "Edit Profile", edit_user_registration_path %></li>
<li><%= link_to "Sign out", destroy_user_session_path, method: :delete %></li>
<% else %>
<li><%= link_to "Sign up", new_user_registration_path %></li>
<li><%= link_to "Sign in", new_user_session_path %></li>
<% end %>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
我确定我在这里遗漏了什么...但是什么? TIA求助!
答案 0 :(得分:2)
看起来你有额外的&lt;%end%&gt;在_navbar.html.erb文件中。