Rails link_to for destroy action:如何传递参数,数据确认动作和instyle css

时间:2016-02-27 08:56:38

标签: ruby-on-rails ruby-on-rails-4 link-to

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

我的上述代码工作正常,

但是如何在我的视图中给我的link_to颜色说ike red?尝试了很多堆栈溢出线程但是找不到解决方案,因为我的link_to包含数据确认操作等组合功能传递参数

1 个答案:

答案 0 :(得分:3)

为链接提供颜色属性

<强> 1。与css类的新链接

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

<强> application.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;' %>