I have a function that needs params passed. The function is:
private
def file_type(file)
# code content
end
I am trying to access the code from the same model file using these methods:
has_one_attached :image, dependent: :destroy
has_one_attached :image1, dependent: :destroy
before_validation :file_type, file: :image
before_validation :file_type, file: :image1
before_validation :file_type(params[:image])
before_validation :file_type(params[:image1])
And a few others but non of them work. Is there a way to pass in the params without having to create a new validation class file
CodePudding user response:
Create a method in your class that passes the parameters.
before_validation :file_types
def file_types
file_type(image)
file_type(image1)
end