Sha256: d6cd527ca914fa5dc3410bfa796bf189861269781a34a70a4e596cb64b9a5a21

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

require_dependency "very_simple_cms/application_controller"

module VerySimpleCms
  class ContentsController < ApplicationController
    def update
      data = params['content']

      data.each do |key, value|
        static_text = HtmlBlock.find_by_attribute(dynamic_save_source, :title, key)
        if static_text.present?
          static_text.update_attributes(body: value['value'])
        else
          static_text = HtmlBlock.new(
            dynamic_source: dynamic_save_source,
            title: key, 
            body: value['value']
          )
          static_text.save
        end
        Rails.cache.write(cache_name_string(key), (static_text.try(:body).html_safe))
      end
      render text: ""
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
very_simple_cms-0.0.3 app/controllers/very_simple_cms/contents_controller.rb