Q:

button_to in Rails 4 : Redirection to Controller action with params and Bootstrap Class

In my Rails 4 project, in a Customer view I want to define a button_to , to call the my_method in my customer controller. Also I want to pass some params also with bootstarp class: class: "btn btn-primary".
I tried this :
<td><%= button_to "Charge Customer",charge_lease_customer_customers_path, params: { doc_delete: true }, class: "btn btn-primary" %></td>

In my routes.rb
get 'charge_lease_customer' => 'customers#charge_lease_customer', as: :charge_lease_customer

When I click on the button the following error screen appears:
No route matches [POST] "/customers/charge_lease_customer"

How to achive it ?

A:

<%= button_to "Charge Customer", charge_lease_customer_customers_path, method: :get, params: { doc_delete: true }, class: "btn btn-primary" %>

As per the docs:

If no :method modifier is given, it will default to performing a POST operation

--
Since your route is a GET request, the Rails does not recognize what you're trying to write. Your button_to helper is populating the route with a POST verb. You need to explicitly define method: :get in order to make the routing valid

You should also look at your routes, specifically that, wherever possible, you should be scoping your routes around your resources:
#config/routes.rb
resources :customers do 
   get :charge_lease_customer, on: :collection
end

Update
You shouldn't be passing pre-defined data through your routes unless the data is openly changeable. IE maybe you wanted to set doc_delete or whatever.
If you want to edit a particular customer, you'll want a member route:
#config/routes.rb
resources :companies do
   get :charge_lease_customer, on: :member #-> url.com/customers/:id/charge_lease_customer
end 

The value of this is that it allows you to pass the :id param, which can be picked up by your controller:
#app/controllers/customers_controller.rb
class CustomersController < ApplicationController
   def charge_lease_customer
      @customer = Customer.find params[:id] 
      # do something with @customer
   end 
end

--
If you wanted to pass customer-specific data through your params, you'll have to make sure it's all on a "top level" param structure:
<%= button_to "x", button_path, params: { customer_id: @customer.id, customer_name: @customer_name } %>

This is not recommended - too much configuration.

