Class: Thredded::PostModerationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ModerationState
Defined in:
app/models/thredded/post_moderation_record.rb

Class Method Summary collapse

Class Method Details

.record!(moderator:, post:, previous_moderation_state:, moderation_state:) ⇒ Thredded::PostModerationRecord

Returns the newly created persisted record.

Parameters:

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/thredded/post_moderation_record.rb', line 39

def self.record!(moderator:, post:, previous_moderation_state:, moderation_state:)
  # Rails 4 doesn't support enum _prefix
  if Rails::VERSION::MAJOR < 5
    previous_moderation_state = moderation_states[previous_moderation_state.to_s]
  end
  create!(
    previous_moderation_state: previous_moderation_state,
    moderation_state:          moderation_state,
    moderator:                 moderator,
    post:                      post,
    post_content:              post.content,
    post_user:                 post.user,
    post_user_name:            post.user.try(:thredded_display_name),
    messageboard_id:           post.messageboard_id,
  )
end