Sha256: 8aae85783e3e0d88d4118ca6ae1b1e2f72b27b477d03774860d9ebb3e481231c

Contents?: true

Size: 742 Bytes

Versions: 4

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

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

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

    # Preview an update to an existing post
    def update
      @private_post = 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.13.0 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.12.4 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.12.3 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.12.2 app/controllers/thredded/private_post_previews_controller.rb