Refactor render_rewarding_context_message_html method with a guard (#569)
clause
This commit is contained in:
parent
94601cdd87
commit
2400908b9d
1 changed files with 8 additions and 8 deletions
|
|
@ -14,14 +14,14 @@ class BadgeAchievement < ApplicationRecord
|
|||
before_validation :render_rewarding_context_message_html
|
||||
|
||||
def render_rewarding_context_message_html
|
||||
if rewarding_context_message_markdown.present?
|
||||
parsed_markdown = MarkdownParser.new(rewarding_context_message_markdown)
|
||||
html = parsed_markdown.finalize
|
||||
final_html = ActionController::Base.helpers.sanitize html,
|
||||
tags: %w(strong em i b u a code),
|
||||
attributes: %w(href name)
|
||||
self.rewarding_context_message = final_html
|
||||
end
|
||||
return if rewarding_context_message_markdown.blank?
|
||||
|
||||
parsed_markdown = MarkdownParser.new(rewarding_context_message_markdown)
|
||||
html = parsed_markdown.finalize
|
||||
final_html = ActionController::Base.helpers.sanitize html,
|
||||
tags: %w(strong em i b u a code),
|
||||
attributes: %w(href name)
|
||||
self.rewarding_context_message = final_html
|
||||
end
|
||||
|
||||
def name_of_user
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue