0

我有这个部分,我在其中使用 if elsif 并在某些条件下在其中形成。由于渲染部分的条件,我遇到了结束标记问题。它说我最后有一个额外的结局。

  <% if (@company_detail.company_logo.blank?)%>
<h3>ADD LOGO</h3>
<% else %>
<img src="<%= "#{@company_detail.company_logo}"%>" class="logo-image" alt="logo"/>
<% end -%>
<div class="overlay align-right">

<%= form_for(:company_detail, :url => {:action => 'changeLogo', :id => @company_detail.id}, :remote => true, :html => {:multipart => true, :method => :post }) do |f| %>

<p style="display:none;">
  <input type="file" name = "logo" id="logoUploadField" accept="image/png,image/gif,image/jpeg,image/jpg" onChange='upload()'/>
  <button id="upload_logo" type="submit"></button>
</p>
<% end -%>  

<% if (@company_detail.company_logo.blank?) %>
<p class="align-right">
  <button class="button small green" id="add_logo" type="reset"><span>Add</span></button>
</p>
<% elsif (@company_detail.company_logo.present?)%>
<%= form_tag({:action => 'removeLogo', :id => @company_detail.id}, :remote => true, :html => {:method => :post }) %>
<p class="align-right">
  <button class="button small green" id="change_logo" type="reset"><span>Change</span></button>
  <button class="button small green" type="submit"><span>Remove</span></button>
  <% end %>
</p>
<% end %>

4

2 回答 2

1

您的问题不包括do第二种形式的类似代码。

<%= form_tag({:action => 'removeLogo', :id => @company_detail.id}, :remote => true, :html => {:method => :post }) do %>
于 2013-05-08T11:18:08.090 回答
1

您忘记了这一行中的“做”:

<%= form_tag({:action => 'removeLogo', :id => @company_detail.id}, :remote => true, :html => {:method => :post }) %>

在此处添加“做”:

<%= form_tag({:action => 'removeLogo', :id => @company_detail.id}, :remote => true, :html => {:method => :post }) do %>

它应该可以工作。

于 2013-05-08T11:14:43.890 回答