Skip to content
Snippets Groups Projects
Commit f721d207 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

has_summernote

parent c7fdc421
No related branches found
No related tags found
No related merge requests found
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
# Remove everything below after migration, please
# TODO put that in summernote-rails
# https://github.com/rails/rails/blob/b961af3345fe2f9e492ba1e5424c2ceb75ac6ead/actiontext/lib/action_text/attribute.rb#L4
def self.has_summernote(name)
class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{name}
# TODO hydrate action-text-attachment
attributes['#{name}'].gsub('</action', 'coucou</action')
end
def #{name}=(value)
# TODO dehydrate action-text-attachment
attributes['#{name}'] = value
end
CODE
end
# TODO Remove everything below after migration, please
def self.summernote(*args)
@@summernote_fields = args
......
......@@ -36,9 +36,10 @@ class Communication::Website::Post < ApplicationRecord
include WithFeaturedImage
include WithBlobs
include WithMenuItemTarget
include WithSlug # We override slug_unavailable? method
include WithSlug # We override slug_unavailable? method`
has_rich_text :text
has_summernote :text_new
summernote :text
......@@ -66,15 +67,6 @@ class Communication::Website::Post < ApplicationRecord
scope :ordered, -> { order(published_at: :desc, created_at: :desc) }
scope :recent, -> { order(published_at: :desc).limit(5) }
def text_new
# TODO hydrate action-text-attachment
attributes['text_new'].gsub('</action', 'coucou</action')
end
def text_new=(value)
# TODO dehydrate action-text-attachment
attributes['text_new'] = value
end
def path
# used in menu_item#static_target
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment