class Admin::AttachmentsController < Admin::AdminController

  before_action :set_attachable_for, only: %i[ new ]


  def new
    @attachments = []
    if params[:asset_ids]
      Asset.where(id: params[:asset_ids].split(',')).each do |asset|
        @attachments << @attachable_for.attachments.new(asset: asset)
      end
    else
      @attachments << @attachable_for.attachments.new
    end
  end




private


  def set_attachable_for
    @attachable_for = Node.find(params[:node_id]) if params[:node_id]
  end


end
