【问题标题】:Rails Link_to text but not display ClassRails Link_to 文本但不显示类
【发布时间】:2019-07-15 11:36:50
【问题描述】:

我已经使用 Rails link_to 和 CSS 类没有任何问题,但我认为我使用正确但它根本不显示

因为我正在尝试将 CSS 创建为 Accept(绿色背景色)和 Decline(红色背景色)

作为简单的文本

<p class="text-center"><%= reservation.status %></p>
   <div class="form-inline">
      <% if reservation.Waiting? %>
      <%= link_to approve_reservation_path(reservation), class:"btn-declined", method: :post do %>  <% end %>
      <%= link_to decline_reservation_path(reservation), class:"btn-approved", method: :post do %>  <% end %>
      <% end %>
  </div>

因为使用了不同的方式,但没有 CSS 只显示文本

控制台日志显示没有用于接受和拒绝的 CSS

CSS 代码

什么是在其上显示 CSS 的替代方法

【问题讨论】:

  • &lt;%= link_to "Approve", approve_reservation_path(reservation), class:"btn-declined", method: :post %&gt; 不加do

标签: css ruby-on-rails ruby-on-rails-5


【解决方案1】:
<p class="text-center"><%= reservation.status %></p>
 <div class="form-inline">
  <% if reservation.Waiting? %>
  <%= link_to "Approve", approve_reservation_path(reservation), class:"btn-declined", method: :post %>
  <%= link_to "Decline", decline_reservation_path(reservation), class:"btn-approved", method: :post %>
  <% end %>

仅当&lt;% if reservation.Waiting? %&gt; 变为真时才会显示链接。

【讨论】:

  • 是的,你是对的,我需要更改 reservation.status 上的代码而不是 reservation.waiting ?,我的错。好像我忽略了它
  • 得到了修复,但你是对的,但我是一个错误的 div 部分,因为我在

    已批准

    已拒绝

  • 很高兴它得到了修复。!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-08
  • 2021-01-17
  • 1970-01-01
  • 1970-01-01
  • 2016-02-22
  • 1970-01-01
相关资源
最近更新 更多