Commit b6cc9e37 by ivan Lan

Fix MediaColumn the condition of skipping refresh_attachments callback

parent 2a1f34d1
......@@ -9,20 +9,20 @@ 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) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment