Search code examples
ruby-on-railsruby-on-rails-4link-to

Rails link_to for destroy action: How to pass parameters, data confirmation action and instyle css


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

My above code working fine,

But how to give my link_to a color say ike red in my view ? Tried many stack overflow threads but couldn't find a solution as my link_to contains a combine functionality like data confirmation action with passing parameters


Solution

  • To give color property to Link

    1. new link with css class

    <%= 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. new link with inline css style

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