```ruby
respond = params[:q] ? Customer.where("name ilike ?", "%#{params[:q]}%").map(&:attributes) 
                     : CustomersDatatable.new(view_context)
respond_to do |format|
   format.html
   format.json { render :json =>  respond }
end  
```