Sha256: 76c1a754ee144cde94598839bab60ef2946dab045e215c405eb13dd21ad3ad0b

Contents?: true

Size: 845 Bytes

Versions: 17

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

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

    before_action :thredded_require_login!
    after_action :verify_authorized

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

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

17 entries across 17 versions & 1 rubygems

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