Sha256: 65b65cf60967de4325a9ed4c0ad4498bc22676435111ca946a8cb50162b82f2a

Contents?: true

Size: 773 Bytes

Versions: 4

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

module Thredded
  class PrivatePostPreviewsController < Thredded::ApplicationController
    include Thredded::RenderPreview

    # Preview a new post
    def preview
      @private_post = Thredded::PrivatePost.new(private_post_params)
      @private_post.postable = Thredded::PrivateTopic.friendly_find!(params[:private_topic_id])
      render_preview
    end

    # Preview an update to an existing post
    def update
      @private_post = Thredded::PrivatePost.find!(params[:private_post_id])
      @private_post.assign_attributes(private_post_params)
      render_preview
    end

    private

    def private_post_params
      params.require(:post)
        .permit(:content)
        .merge(user: thredded_current_user)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thredded-0.16.1 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.0 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.15.5 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.15.4 app/controllers/thredded/private_post_previews_controller.rb