diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 8d115431..94b4282e 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -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( diff --git a/app/models/concerns/has_changelog.rb b/app/models/concerns/has_changelog.rb index 2d543733..5dc9eab6 100644 --- a/app/models/concerns/has_changelog.rb +++ b/app/models/concerns/has_changelog.rb @@ -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, diff --git a/config/environments/development.rb b/config/environments/development.rb index eef5b034..121334cb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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' diff --git a/config/environments/production.rb b/config/environments/production.rb index 5d65c2ce..7bd937d7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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' }