samedi 23 janvier 2016

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 ?

Aucun commentaire:

Enregistrer un commentaire