database_view_record.rb 474 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. module DatabaseViewRecord
  3. extend ActiveSupport::Concern
  4. class_methods do
  5. def refresh
  6. Scenic.database.refresh_materialized_view(
  7. table_name,
  8. concurrently: true,
  9. cascade: false
  10. )
  11. rescue ActiveRecord::StatementInvalid
  12. Scenic.database.refresh_materialized_view(
  13. table_name,
  14. concurrently: false,
  15. cascade: false
  16. )
  17. end
  18. end
  19. def readonly?
  20. true
  21. end
  22. end