Sha256: 6525f5b7401a9c5575553520ccba38279294c81d35c1be138bad658808e9c0e4

Contents?: true

Size: 669 Bytes

Versions: 7

Compression:

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

7 entries across 7 versions & 1 rubygems

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