yaml fallback for changelogs

This commit is contained in:
drusepth 2022-08-17 23:31:55 -07:00
parent bda757f343
commit f09270737f
4 changed files with 13 additions and 1 deletions

View File

@ -508,7 +508,10 @@ class ContentController < ApplicationController
@attribute_field = AttributeField.find_by(id: params[:field_id].to_i)
attribute_value = @attribute_field.attribute_values.order('created_at desc').find_or_initialize_by(entity_params)
attribute_value.user_id ||= current_user.id
attribute_value.value = field_params.fetch('value', '').to_i
new_universe_id = field_params.fetch('value', nil).to_i
new_universe_id = nil if new_universe_id == 0
attribute_value.value = new_universe_id
attribute_value.save!
@content = entity_params.fetch('entity_type').constantize.find_by(

View File

@ -40,6 +40,7 @@ module HasChangelog
before_update do
if self.is_a?(Attribute)
# todo how to get current_user?
ContentChangeEvent.create(
user: find_current_user,
changed_fields: changes,

View File

@ -59,6 +59,10 @@ Rails.application.configure do
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Whitelist HashWithIndifferentAccess/TimeWithZone for changelog serialization
# config.active_record.yaml_column_permitted_classes = [HashWithIndifferentAccess, ActiveSupport::TimeWithZone, Time]
config.active_record.use_yaml_unsafe_load = true
# Set test-mode Stripe API key
Stripe.api_key = "sk_test_v37uWbseyPct6PpsfjTa3y1l"
config.stripe_publishable_key = 'pk_test_eXI4iyJ2gR9UOGJyJERvDlHF'

View File

@ -91,6 +91,10 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Whitelist HashWithIndifferentAccess/TimeWithZone for changelog serialization
# config.active_record.yaml_column_permitted_classes = [HashWithIndifferentAccess, ActiveSupport::TimeWithZone, Time]
config.active_record.use_yaml_unsafe_load = true
# Devise default url options
config.action_mailer.default_url_options = { host: 'www.notebook.ai' }
config.active_job.default_url_options = { host: 'www.notebook.ai' }