不能在 Rails 4.2 中使用 "link_to" 或 "button_to" with Semantic-UI

Cannot use "link_to" or "button_to" in Rails 4.2 with Semantic-UI

我正在使用 Semantic-UI 来设计我的 rails 应用程序设计。我创建了一个卡片布局,在该卡片的底部附有一个按钮。但是当我尝试在底部附加按钮中的文本中添加 link_to 或 button_to 时,一切都会变质。

HTML + Rails 4.2 代码编写:

<div class="ui four cards">
        <a class="red card">
            <div class="image">
                <%= image_tag("white-image.png") %>
            </div>
            <div class="ui bottom attached button">
                <i class="fa fa-cloud-upload"></i><span class="little-space"></span><%= link_to 'Deploy', controller: 'apps', action: 'show'%>

            </div>
        </a>
    </div>

输出:

必须是这样的:


正常的 HTML 和 CSS 可以工作,但是当我尝试使用 Rails4.2 助手,如 "link_to" 或 "button_to" 时,一切都出错了。有什么方法可以使用 Rails 帮助器使整个卡片布局可点击。


生成HTML代码:

<div class="ui four cards">
        <a class="red card">
            <div class="image">
                <img src="/assets/white-image-d3f1bf0d70bdd663809bc001a778b550fc7246e81a614f3ff10e7cfb0a1514cf.png" alt="White image d3f1bf0d70bdd663809bc001a778b550fc7246e81a614f3ff10e7cfb0a1514cf">
            </div>
            </a><div class="ui bottom attached button"><a class="red card">
                <i class="fa fa-cloud-upload"></i><span class="little-space"></span></a><a href="/apps/show">Delpoy</a>

            </div>

    </div>

使用HTML和Semantic-UI的简单输出

<link href="http://semantic-ui.com/dist/semantic.min.css" rel="stylesheet"/>
<script src="http://semantic-ui.com/dist/semantic.min.js"></script>
<div class="ui four cards">
     <a class="red card">
       <div class="image">
        <img class="ui wireframe image" src="http://semantic-ui.com/images/wireframe/white-image.png">
       </div>
       <div class="ui bottom attached button">
          <i class="fa fa-cloud-upload"></i><span class="little-space"></span>Deploy
          
       </div>
      </a>
  </div>

link_tobutton_to 都接受一个块,该块可用于在 link/button.

中插入任意内容
<div class="ui four cards">
  <%= link_to({ controller: 'apps', action: 'show' }, { class: "red card" }) do %>
    <div class="image">
      <%= image_tag "white-image.png", class: "ui wireframe image" %>
    </div>
    <div class="ui bottom attached button">
      <i class="fa fa-cloud-upload"></i><span class="little-space"></span>Deploy
    </div>
  <% end %>
</div>

link_to 可以接受一个块,试试这个:

<div class="ui four cards">
    <%= link_to {controller: 'apps', action: 'show'}, {class: "red card"} do %>
        <div class="image">
            <%= image_tag("white-image.png") %>
        </div>
        <div class="ui bottom attached button">
            <i class="fa fa-cloud-upload"></i>
        <span class="little-space"></span>
            Deploy
        </div>
    <% end %>
</div>