Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
8e8dab46
Commit
8e8dab46
authored
3 years ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
better
parent
44f9efaa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/application_record.rb
+17
-0
17 additions, 0 deletions
app/models/application_record.rb
app/models/communication/website/post.rb
+2
-6
2 additions, 6 deletions
app/models/communication/website/post.rb
with
19 additions
and
6 deletions
app/models/application_record.rb
+
17
−
0
View file @
8e8dab46
class
ApplicationRecord
<
ActiveRecord
::
Base
self
.
abstract_class
=
true
# Remove everything below after migration, please
def
self
.
summernote
(
*
args
)
@@summernote_fields
=
args
end
before_validation
:summernote
def
summernote
@@summernote_fields
.
each
do
|
field
|
self
[
"
#{
field
}
_new"
]
=
send
(
field
).
to_s
.
gsub
(
'<div>'
,
'<p>'
)
.
gsub
(
'</div>'
,
'</p>'
)
.
gsub
(
'<p><br></p>'
,
''
)
end
end
end
This diff is collapsed.
Click to expand it.
app/models/communication/website/post.rb
+
2
−
6
View file @
8e8dab46
...
...
@@ -40,6 +40,8 @@ class Communication::Website::Post < ApplicationRecord
has_rich_text
:text
summernote
:text
has_one
:imported_post
,
class_name:
'Communication::Website::Imported::Post'
,
dependent: :destroy
...
...
@@ -60,8 +62,6 @@ class Communication::Website::Post < ApplicationRecord
before_validation
:set_published_at
,
if: :published_changed?
before_validation
:summernote
scope
:published
,
->
{
where
(
published:
true
)
}
scope
:ordered
,
->
{
order
(
published_at: :desc
,
created_at: :desc
)
}
scope
:recent
,
->
{
order
(
published_at: :desc
).
limit
(
5
)
}
...
...
@@ -107,8 +107,4 @@ class Communication::Website::Post < ApplicationRecord
def
inherited_blob_ids
[
best_featured_image
&
.
blob_id
]
end
def
summernote
self
.
text_new
=
self
.
text
.
to_s
.
gsub
(
'<div>'
,
'<p>'
).
gsub
(
'</div>'
,
'</p>'
).
gsub
(
'<p><br></p>'
,
''
)
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment