Sha256: a96d2f75f00316261f0b8019aeee1d1f0620ec581ed3018b0e6431d62fbf9234

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 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
      end
      render text: ""
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
very_simple_cms-0.0.2 app/controllers/very_simple_cms/contents_controller.rb
very_simple_cms-0.0.1 app/controllers/very_simple_cms/contents_controller.rb