ruby on rails 报告中的分页错误

阿努贾德克斯

我最近开始学习 ruby​​-on-rails,现在我已经到了可以创建一些东西但仍然不太熟悉语法的地步。在报告视图中,当我分页到第二页时,它给了我一个错误。

但是分页在昨天得到了纠正。今天我使用 params.dig 方法编辑了一些复选框来保存复选框值。这些值也需要在第二页中显示。我的控制器有什么问题

这是我的看法

 %br
          .row
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]","CUS", params.dig('search_customer_supplier', 'accounts_dealer_types.dealer_code') == "CUS"
              = label_tag "Organizational Customer"
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]", "SUP", params.dig('search_customer_supplier', 'accounts_dealer_types.dealer_code') == "SUP"
              = label_tag "Organzational Supplier"
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]", "INDCUS", params.dig('search_customer_supplier', 'accounts_dealer_types.dealer_code') == "INDCUS"
              = label_tag "Individual Customer"
            .col-md-3
              = check_box_tag "search_customer_supplier[accounts_dealer_types.dealer_code][]", "INDSUP", params.dig('search_customer_supplier', 'accounts_dealer_types.dealer_code') == "INDSUP"
              = label_tag "Individual Supplier"

这是我的控制器

 def customer_supplier_report
    Organization
    Address
    ContactNumber
    refined_query = ""
    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?

      # puts params[:search_customer_supplier]['accounts_dealer_types.dealer_code']

      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

在我的浏览器中显示控制器中的错误行在哪里。那些是,

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?

这是我得到的输出错误

ReportsController#customer_supplier_report 中的 NoMethodError

“CUS”的未定义方法`join':String 你的意思是?JSON

维沙尔

因为您收到此错误join()是的方法Array class但是您的参数值是字符串类型。

IE。

[1,2,3].join(' OR ') #=> "1 OR 2 OR 3"

"aasd".join('OR') #=> will throw exception which you are getting.

检查您的参数值是否是正确的数组

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Ruby Rails中的Heisenbug错误

来自分类Dev

Ruby on Rails 中的路由错误

来自分类Dev

Ruby on Rails路由错误

来自分类Dev

分页集成测试(Ruby on Rails)

来自分类Dev

Ruby on Rails和Kaminari分页

来自分类Dev

Ruby on Rails模型中的<<

来自分类Dev

Ruby on Rails中的Mailer

来自分类Dev

在Ruby on Rails中@或不@

来自分类Dev

ruby on rails 中的 Turbolinks

来自分类Dev

在 Ruby on rails 中解码

来自分类Dev

Ruby on Rails-AJAX分页中的JQuery未运行

来自分类Dev

Ruby on Rails中按字母顺序分页的单词

来自分类Dev

Ruby on Rails中的form_for错误消息

来自分类Dev

Ruby on Rails中的Coffeescript编译错误

来自分类Dev

Ruby on Rails中的种子文件错误

来自分类Dev

Spree / Ruby on Rails中的资产路径错误

来自分类Dev

Ruby on Rails中的种子文件错误

来自分类Dev

在Ruby on Rails中创建哈希的零错误

来自分类Dev

搜索中的Ruby on Rails Controller错误

来自分类Dev

*#view for Ruby on Rails中的参数错误

来自分类Dev

Ruby on Rails Mailer 中的操作视图错误

来自分类Dev

Ruby on Rails 错误使用 Rails 方法

来自分类Dev

Ruby on Rails错误捆绑器

来自分类Dev

错误Rails-libxml-Ruby

来自分类Dev

Rails使用的是错误版本的Ruby

来自分类Dev

Ruby on Rails-回形针错误

来自分类Dev

参数丢失错误-Ruby on Rails

来自分类Dev

阻止错误学习Ruby on Rails

来自分类Dev

Ruby on Rails模型创建错误