From e8053d6e7df327310f34603ff13f56da2dc128f5 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Wed, 2 Jan 2019 15:24:13 +0100 Subject: [PATCH] FIX: Polls didn't work in imported posts Imports skip validation of posts, but polls are only created during the validation phase. --- app/models/post.rb | 4 ++-- lib/post_creator.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index a923d1da05..7279a0ff27 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -55,13 +55,13 @@ class Post < ActiveRecord::Base has_many :user_actions, foreign_key: :target_post_id - validates_with ::Validators::PostValidator + validates_with ::Validators::PostValidator, unless: :skip_validation after_save :index_search after_save :create_user_action # We can pass several creating options to a post via attributes - attr_accessor :image_sizes, :quoted_post_numbers, :no_bump, :invalidate_oneboxes, :cooking_options, :skip_unique_check + attr_accessor :image_sizes, :quoted_post_numbers, :no_bump, :invalidate_oneboxes, :cooking_options, :skip_unique_check, :skip_validation LARGE_IMAGES ||= "large_images".freeze BROKEN_IMAGES ||= "broken_images".freeze diff --git a/lib/post_creator.rb b/lib/post_creator.rb index 62d2c39dd6..c5c09d04d1 100644 --- a/lib/post_creator.rb +++ b/lib/post_creator.rb @@ -476,7 +476,8 @@ class PostCreator def save_post @post.disable_rate_limits! if skip_validations? - saved = @post.save(validate: !skip_validations?) + @post.skip_validation = skip_validations? + saved = @post.save rollback_from_errors!(@post) unless saved end