ruby-on-railstrixactiontext

How can you check if a Rails rich_text_field (Action Text) is blank?


I can't seem to find this anywhere - the console shows the field as nil but in reality action text is storing the content which could be 'blank'.

MyModel.rich_text_field.nil? returns false regardless if the actual content is blank or not.


Solution

  • You can check if your model field is blank with:

    MyModel.rich_text_field.blank?