Skip to content

Check column type to ignore binary columns #68

@scambra

Description

@scambra

It would be good to don't strip on binary columns (@sql_type="mediumblob", @type=:binary). I had the callback added to ApplicationRecord, and had "invalid byte sequence in UTF-8" error on a binary column. I think strip_record could check the column.

Also, supporting a symbol for except or only to be a method name, or supporting proc, could be used to call strip_attributes in ApplicationRecord, and then define a method with the excluded columns:

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
  strip_attributes allow_empty: true, except: :not_stripped_columns
end
class Picture < ApplicationRecord
  def not_strippped_columns
    [:picture]
  end
end

Or with proc:

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
  strip_attributes allow_empty: true, except: proc { |record| record.not_stripped_columns }
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions