Skip to content

Exception "TypeError: no implicit conversion of nil into String" when listing files in section #756

@neilabdev

Description

@neilabdev

While trying to use the bcms_kcfinder module in rails 3.2.22.2 and BrowserCMS 3.5.7, I notice it was receiving various errors, which I traced back to an exception cause when trying to list files in a given section. To test, you can run the following in the console:

@section = Cms::Section.last
Cms::ImageBlock.by_section(@section)

Which Returns:

2.3.0 :002 > Cms::ImageBlock.by_section(@section)
  Cms::SectionNode Load (0.2ms)  SELECT `section_nodes`.* FROM `section_nodes` WHERE `section_nodes`.`node_id` = 3 AND `section_nodes`.`node_type` = 'Cms::Section' LIMIT 1
TypeError: no implicit conversion of nil into String
    from /Users/ghost/.rvm/gems/ruby-2.3.0@csp_development/gems/arel-3.0.3/lib/arel.rb:40:in `initialize'
    from /Users/ghost/.rvm/gems/ruby-2.3.0@csp_development/gems/arel-3.0.3/lib/arel.rb:40:in `new'
    from /Users/ghost/.rvm/gems/ruby-2.3.0@csp_development/gems/arel-3.0.3/lib/arel.rb:40:in `sql'
    from /Users/ghost/.rvm/gems/ruby-2.3.0@csp_development/gems/activerecord-3.2.22.2/lib/active_record/associations/join_helper.rb:47:in `block in sanitize'
    from /Users/ghost/.rvm/gems/ruby-2.3.0@csp_development/gems/activerecord-3.2.22.2/lib/active_record/associations/join_helper.rb:45:in `map'
    from /Users/ghost/.rvm/gems/ruby-2.3.0@csp_development/gems/activerecord-3.2.22.2/lib/active_record/associations/join_helper.rb:45:in `sanitize'
    from /Users/ghost/.rvm/gems/ruby-2.3.0@csp_development/gems/activerecord-3.2.22.2/lib/active_record/associations/join_dependency/join_association

The file causing the issue:

#app/assets/models/cms/abstract_file_block.rb
module Cms
  class AbstractFileBlock < ActiveRecord::Base
    self.table_name = Namespacing.prefix("file_blocks")
    validates_presence_of :name

    ### Error caused Here
    scope :by_section, lambda { |section| {
       :include => {:attachments => :section_node},
        :conditions => ["#{SectionNode.table_name}.ancestry = ?", section.node.ancestry_path]}
    }
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions