Sha256: 60faa77a59c8b46b6fdfb4073c66ac8f0d1645f7e6280d04970cecb81ac9d56e

Contents?: true

Size: 670 Bytes

Versions: 4

Compression:

Stored size: 670 Bytes

Contents

# frozen_string_literal: true

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

    # Preview a new post
    def preview
      @post = Post.new(post_params)
      @post.postable = Topic.friendly_find!(params[:topic_id])
      render_preview
    end

    # Preview an update to an existing post
    def update
      @post = Post.find(params[:post_id])
      @post.assign_attributes(post_params)
      render_preview
    end

    private

    def post_params
      params.require(:post)
        .permit(:content)
        .merge(user: thredded_current_user, messageboard: messageboard)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thredded-0.13.0 app/controllers/thredded/post_previews_controller.rb
thredded-0.12.4 app/controllers/thredded/post_previews_controller.rb
thredded-0.12.3 app/controllers/thredded/post_previews_controller.rb
thredded-0.12.2 app/controllers/thredded/post_previews_controller.rb