销毁操作的 Rails link_to:如何传递参数、数据确认操作和样式 css


<%= link_to "[Delete]", customer_path(customer.id, :customer_delete => true), :method => :delete, :data => {:confirm => "Are You Sure?"} %>

我上面的代码工作正常,

但是如何给我的link_to一种颜色,比如说我眼中的红色?尝试了许多堆栈溢出线程,但找不到解决方案,因为我的link_to包含组合功能,例如数据确认操作和传递参数

为链接提供颜色属性

1. 与 CSS 类的新链接

<%= link_to "[Delete]", customer_path(customer.id, :customer_delete => true), :method => :delete, :data => {:confirm => "Are You Sure?"}, :class => 'link' %>

应用.css

.link {
  color: red;
}

2. 内联 CSS 样式的新链接

<%= link_to "[Delete]", customer_path(customer.id, :customer_delete => true), :method => :delete, :data => {:confirm => "Are You Sure?"}, :style => 'color: red;' %>

最新更新