I have a customer model and controller in my rails application. In my customers listing index page I am displaying all customers with search filter options to display customers according to their purchase type (Sale, Lease, Trial).
@customers = Customer.where(customer_type: ["Sale","Lease","Trail"]).count
If the count > 0
I want to update their customer_type
field to its capitalized form (Sale -> SALE , Lease -> LEASE, Trail -> TRAIL) for all customers in the @customers
collection .
How to achieve it in a most optimised way ?
Aucun commentaire:
Enregistrer un commentaire