Module: Thredded::PostAttachments::TopicFormAttributes
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/thredded/post_attachments.rb
Instance Method Summary collapse
Instance Method Details
#initialize(params = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/thredded/post_attachments.rb', line 50 def initialize(params = {}) @title = params[:title] @category_ids = params[:category_ids] @locked = params[:locked] || false @sticky = params[:sticky] || false @content = params[:content] @user = params[:user] || fail('user is required') @messageboard = params[:messageboard] if params.has_key?(:post) @attachment = params[:post].try(:[], :attachment) elsif params.has_key?(:attachment_attributes) @attachment = params[:attachment_attributes] else @attachment = nil end end |
#post ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/thredded/post_attachments.rb', line 68 def post @post ||= topic.posts.build( content: content, user: non_null_user, messageboard: ) if @attachment.present? @post. = @attachment else @post. end @post end |