Reputation: 81
I'm trying to get two different types of tags working using the acts_as_taggable_on gem. I was following this link. I'm getting this error:
syntax error, unexpected keyword_ensure, expecting keyword_end yntax error, unexpected end-of-input, expecting keyword_end
The error says the problem is line 92 of my show.html.erb, but when I put and <% end %> there, it doesn't fix it.
show.html.erb
<%- title "#{@artwork.title} — a #{@artwork.category.downcase} by Peter Bentley"%>
<% if user_signed_in? %>
<div class="row">
<div class="col-md-12">
<%= link_to 'Edit', edit_artwork_path(@artwork) %> |
<%= link_to 'Artworks Table', admin_path %>
</div>
</div>
<% end %>
<div class="row">
<div class="col-md-8">
<%= image_tag(@artwork.image.url, :class => 'img-responsive') %>
</div>
<div class="col-xs-12 col-md-4">
<p class="field-label">Title</p>
<h1><%= @artwork.title %></h1>
</div>
<div class="col-xs-6 col-sm-3 col-md-4">
<p class="field-label">Medium</p>
<h3><%= @artwork.medium %></h3>
</div>
<% unless @artwork.date.blank? %>
<div class="col-xs-6 col-sm-3 col-md-2">
<p class="field-label">Date</p>
<h3><%= @artwork.date.strftime("%b %d %Y") %></h3>
</div>
<% end %>
<% unless @artwork.height.blank? | @artwork.width.blank?%>
<div class="col-xs-6 col-sm-3 col-md-4">
<p class="field-label">Size</p>
<h3><%= @artwork.height %> x <%= @artwork.width %> in.</h3>
</div>
<% end %>
<div class="col-xs-6 col-sm-3 col-md-2">
<p class="field-label">Genre</p>
<h3><%= @artwork.genre %></h3>
</div>
<div class="col-xs-6 col-sm-3 col-md-2">
<p class="field-label">Category</p>
<h3><%= @artwork.category %></h3>
</div>
<% unless @artwork.availability.blank? %>
<div class="col-xs-12 col-sm-3 col-md-4">
<% if @artwork.availability == 'Available for purchase' %>
<p class="field-label">Availability</p>
<h3><%= @artwork.availability %></h3>
<%= link_to "Add to Inquiry List", root_path, class: "btn btn-primary" %>
<% else %>
<p class="field-label">Availability</p>
<h3><%= @artwork.availability %></h3>
<% end %>
</div>
<% end %>
<% unless @artwork.series.blank? %>
<div class="col-xs-6 col-sm-6 col-md-4">
<p class="field-label">Series</p>
<% @artwork.series.each do |series| %>
<span class="tags">
<%= link_to series.name, series_url(:series => series.name) %>
</span>
</div>
<% end %>
<% unless @artwork.tags.blank? %>
<div class="col-xs-6 col-sm-6 col-md-4">
<p class="field-label">Tags</p>
<% @artwork.tags.each do |tag| %>
<span class="tags">
<%= link_to tag.name, tagged_url(:tag => tag.name) %>
</span>
</div>
<% end %>
</div> <!-- end of 'row' div -->
<div class="fixed-prev-next">
<div class="btn-group" role="group" aria-label="...">
<%= link_to "Previous", @artwork.previous, :class => "btn btn-default" if @artwork.previous.present? %>
<%= link_to "Next", @artwork.next, :class => "btn btn-default" if @artwork.next.present? %>
</div>
</div>
<% end %>
artworks_controller.erb has
def index
if params[:tag]
@artworks = Artwork.tagged_with(params[:tag])
else
@artworks = Artwork.all
end
end
def tagged
if params[:tag].present?
@artworks = Artwork.tagged_with(params[:tag])
else
@artworks = Artwork.all
end
end
def series
if params[:series].present?
@artworks = Artwork.tagged_with(params[:series])
else
@artworks = Artwork.all
end
end
and private method that permits
:tag_list, :tag, :series_list, :series
artwork.rb has
acts_as_taggable
acts_as_taggable_on :tags, :series
What am I doing wrong?
Upvotes: 0
Views: 2908
Reputation: 18090
You are failing to close 2 of your loops with an <% end %>
.
<% unless @artwork.series.blank? %>
<div class="col-xs-6 col-sm-6 col-md-4">
<p class="field-label">Series</p>
<% @artwork.series.each do |series| %>
<span class="tags">
<%= link_to series.name, series_url(:series => series.name) %>
</span>
<%# Need end here, as illustrated on the next line. %>
<% end %>
</div>
<% end %>
<% unless @artwork.tags.blank? %>
<div class="col-xs-6 col-sm-6 col-md-4">
<p class="field-label">Tags</p>
<% @artwork.tags.each do |tag| %>
<span class="tags">
<%= link_to tag.name, tagged_url(:tag => tag.name) %>
</span>
<%# Need end here, as illustrated on the next line. %>
<% end %>
</div>
<% end %>
Take more care about how you're indenting your code. It matters and helps you to more easily prevent and debug syntax problems like this.
Upvotes: 2