mardi 14 mai 2019

How to hold the checkbox params in rails after search

The search is working fine but the problem is that when i print the excel report according to the result.it is showing all the values in the database, filter is not working.Realoding all over the page, then Checkbox true values are gone. How to hold the params after refreshing the page

   .row
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]","CUS", false
              = label_tag "Organizational Customer"
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]", "SUP", false, class: "first_resolution"
              = label_tag "Organzational Supplier"
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]", "INDCUS", false, class: "first_resolution"
              = label_tag "Individual Customer"
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]", "INDSUP", false, class: "first_resolution"
              = label_tag "Individual Supplier"

This is my controller,

    if params[:search].present? or params[:excel_report].present?

      search_customer_supplier = params[:search_customer_supplier]
      if params[:organization_children].present? and search_customer_supplier["id"].present?
        organization_id = search_customer_supplier["id"]
        organization = Organization.find(organization_id)
        anchestor_ids = organization.anchestors.map{|o| o[:member].id }
        search_customer_supplier["id"] = "(#{anchestor_ids.join(' OR ')})" if anchestor_ids.any?
      end
      params[:search_customer_supplier]['accounts_dealer_types.dealer_code'] = params[:search_customer_supplier]['accounts_dealer_types.dealer_code'].join(" OR ") if params[:search_customer_supplier]['accounts_dealer_types.dealer_code'].present?

      @all_address = params[:all_address].to_bool if params[:all_address].present?
      customer_report = params[:search_customer_supplier].map { |k, v| "#{k}:#{v}" if v.present? }.compact
    else
      customer_report = ["accounts_dealer_types.dealer_code:(CUS OR SUP OR INDCUS OR INDSUP)"]
    end

Aucun commentaire:

Enregistrer un commentaire