Skip to content

[avaram] Skip save on specified field if this fields content is blank in before_save #1701

Answered by jwoertink
zw963 asked this question in Q&A
Discussion options

You must be logged in to vote

If you remove the licenses_allowed_creation_times from the permit_columns, then it won't set the value from params.

class UpdateUser < User::SaveOperation
  permit_columns password
  
  before_save do
	
	# others password update logic here.
  end
end

If you need it in some cases, you could have a separate operation for that.

class UpdateUserPassword < User::SaveOperation
  include DefaultUserValidations
  permit_columns password
end

class UpdateUserLicenses < User::SaveOperation
  include DefaultUserValidations
  permit_columns licenses_allowed_creation_times
end

You could try something like that.

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@jwoertink
Comment options

@zw963
Comment options

@jwoertink
Comment options

@jwoertink
Comment options

@zw963
Comment options

Answer selected by zw963
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants