Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check column type to ignore binary columns #68

Open
scambra opened this issue Jul 16, 2024 · 0 comments
Open

Check column type to ignore binary columns #68

scambra opened this issue Jul 16, 2024 · 0 comments

Comments

@scambra
Copy link

scambra commented Jul 16, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant