Skip to content

Weird things on String Column error: "some_column_name is required". #1708

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

You must be logged in to vote

In Lucky, we treat "" the same as nil because this helps with additional type-safety. For example, say you have a name column that gets displayed on a page. If it got set to "", the page would render a blank space, and you wouldn't know until production.

We have 2 ways around this:

class CreateSysConfig < SysConfig::SaveOperation
  permit_columns private_key, deleted_at
  # add this to skip validating the required fields
  skip_default_validations
end

or
2.

class CreateSysConfig < SysConfig::SaveOperation
  permit_columns private_key, deleted_at
  
  before_save do
    # allow the private_key to be blank
    private_key.allow_blank = true
  end
end

I think we're missing docs on these, …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zw963
Comment options

Answer selected by stephendolan
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