Class: Thredded::PostPreviewsController

Inherits:
ApplicationController show all
Includes:
RenderPreview
Defined in:
app/controllers/thredded/post_previews_controller.rb

Instance Method Summary collapse

Methods included from UrlsHelper

#delete_post_path, #edit_post_path, #edit_preferences_path, #edit_preferences_url, #mark_unread_path, #permalink_path, #post_path, #post_url, #quote_post_path, #search_path, #send_private_message_path, #topic_path, #topic_url, #unread_topics_path, #user_path

Instance Method Details

#previewObject

Preview a new post



11
12
13
14
15
16
# File 'app/controllers/thredded/post_previews_controller.rb', line 11

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

#updateObject

Preview an update to an existing post



19
20
21
22
23
24
# File 'app/controllers/thredded/post_previews_controller.rb', line 19

def update
  @post = Thredded::Post.find!(params[:post_id])
  authorize @post, :update?
  @post.assign_attributes(post_params)
  render_preview
end