Sha256: cf11186a42699f65ccfa9cb3c0e6ae76c61575a4e61c6160ec5f059ad93c314c

Contents?: true

Size: 741 Bytes

Versions: 7

Compression:

Stored size: 741 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

7 entries across 7 versions & 1 rubygems

Version Path
thredded-0.12.1 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.12.0 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.11.1 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.11.0 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.10.1 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.10.0 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.9.4 app/controllers/thredded/private_post_previews_controller.rb