Sha256: 69db14e7ac62d35be66dc5f91962fcd262658a5c936f93cd866418b7e4907289

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

module Irwi::Extensions::Controllers::WikiPageAttachments

  def add_attachment
    attachment = page_attachment_class.new(permitted_page_attachment_params)
    attachment.save!
    redirect_to url_for(:path => attachment.page.path, :action => :edit)
  end

  def remove_attachment
    attachment = page_attachment_class.find(params[:attachment_id])
    attachment.destroy
    redirect_to url_for(:path => attachment.page.path, :action => :edit)
  end

  private

  def page_attachment_class
    Irwi.config.page_attachment_class
  end

  def permitted_page_attachment_params
    params.require(:wiki_page_attachment).permit(:page_id, :wiki_page_attachment)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
irwi-0.5.0 lib/irwi/extensions/controllers/wiki_page_attachments.rb