Sha256: 28736daeba5ffc50c4b67f92904a4a5c6af122c201a8ee6a09df5f096b13a2be

Contents?: true

Size: 700 Bytes

Versions: 17

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

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

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

    # Preview an update to an existing post
    def update
      @post = Thredded::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

17 entries across 17 versions & 2 rubygems

Version Path
thredded-0.15.3 app/controllers/thredded/post_previews_controller.rb
thredded-0.15.2 app/controllers/thredded/post_previews_controller.rb
thredded-0.15.1 app/controllers/thredded/post_previews_controller.rb
threddedDANIEL-0.14.5 app/controllers/thredded/post_previews_controller.rb
thredded-0.14.4 app/controllers/thredded/post_previews_controller.rb
thredded-0.14.3 app/controllers/thredded/post_previews_controller.rb
thredded-0.14.2 app/controllers/thredded/post_previews_controller.rb
thredded-0.14.1 app/controllers/thredded/post_previews_controller.rb
thredded-0.14.0 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.8 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.7 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.6 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.5 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.4 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.3 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.2 app/controllers/thredded/post_previews_controller.rb
thredded-0.13.1 app/controllers/thredded/post_previews_controller.rb