Sha256: 76855f1f1aca2c1c4cedc64cba206fc65237fc9a45d508c01450e1069c5f8064

Contents?: true

Size: 933 Bytes

Versions: 17

Compression:

Stored size: 933 Bytes

Contents

# frozen_string_literal: true

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

    before_action :thredded_require_login!
    after_action :verify_authorized

    # 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])
      authorize @private_post, :create?
      render_preview
    end

    # Preview an update to an existing post
    def update
      @private_post = Thredded::PrivatePost.find!(params[:private_post_id])
      authorize @private_post, :update?
      @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

17 entries across 17 versions & 1 rubygems

Version Path
thredded-1.1.0 app/controllers/thredded/private_post_previews_controller.rb
thredded-1.0.1 app/controllers/thredded/private_post_previews_controller.rb
thredded-1.0.0 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.16 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.15 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.14 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.13 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.12 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.11 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.10 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.9 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.8 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.7 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.6 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.5 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.4 app/controllers/thredded/private_post_previews_controller.rb
thredded-0.16.3 app/controllers/thredded/private_post_previews_controller.rb