Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
whaleback
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
whaleback
Commits
b6cc9e37
Commit
b6cc9e37
authored
Jul 16, 2018
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MediaColumn the condition of skipping refresh_attachments callback
parent
2a1f34d1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
media_column.rb
lib/whaleback/media_column.rb
+6
-6
No files found.
lib/whaleback/media_column.rb
View file @
b6cc9e37
...
...
@@ -9,21 +9,21 @@ module Whaleback
def
media_url_column
column
,
column_parse
=
Proc
.
new
(
&
:itself
)
collection
=
"
#{
column
}
_attachments"
has_many
collection
.
to_sym
,
->
{
where
(
column_name:
column
)
},
class_name:
'Whaleback::Media::Attachment'
,
as: :attached
,
dependent: :destroy
after_save
{
refresh_attachments
(
column_parse
.
call
(
send
(
column
)),
column
)
if
"saved_change_to_
#{
column
}
?"
.
to_sym
after_save
if:
"saved_change_to_
#{
column
}
?"
.
to_sym
{
refresh_attachments
(
column_parse
.
call
(
send
(
column
)),
column
)
}
end
def
media_url_columns
*
columns
columns
.
each
{
|
column
|
media_url_column
(
column
)
}
end
def
rich_text_column
column
media_url_column
column
,
Proc
.
new
{
|
val
|
Nokogiri
::
HTML
(
val
).
xpath
(
'//img'
).
map
{
|
ele
|
ele
.
attr
(
'src'
)
}
}
end
def
media_url_columns
*
columns
columns
.
each
{
|
column
|
media_url_column
(
column
)
}
end
def
rich_text_columns
*
columns
columns
.
each
{
|
column
|
rich_text_column
(
column
)
}
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment