class Sadmin::AttachmentsController

Controlador para la gestión de ficheros adjuntos a News, Event y Page

Public Instance Methods

create() click to toggle source

Creación de nuevo fichero adjunto

# File app/controllers/sadmin/attachments_controller.rb, line 35
def create
  @attachment = @attachable.attachments.new({:attachable_type => params[:attachable_type], :attachable_id => params[:attachable_id]}.merge(params[:attachment]))
  if @attachment.save
    flash[:notice] = t('sadmin.guardado_correctamente', :article => Attachment.human_name.gender_article, :what => Attachment.human_name)  
    redirect_to sadmin_document_page_url(@attachable)
  else
    render :action => "new"
  end
end
destroy() click to toggle source

Eliminación de un fichero

# File app/controllers/sadmin/attachments_controller.rb, line 63
def destroy
  #@attachment = Attachment.find(params[:id])
  if @attachment.destroy
    flash[:notice] = t('sadmin.eliminado_correctamente', :article => @attachment.class.human_name.gender_article, :what => @attachment.class.human_name)
  else
    flash[:error] = t('sadmin.no_eliminado_correctamente', :article => @attachment.class.human_name.gender_article, :what => @attachment.class.human_name)
  end
  redirect_to sadmin_document_page_url(@attachment.attachable)
end
edit() click to toggle source

Modificación de los atributos de un fichero

# File app/controllers/sadmin/attachments_controller.rb, line 46
def edit
  #@attachment = Attachment.find(params[:id])
  @title = t('sadmin.modificar_what', :what => @attachment.class.human_name)
end
new() click to toggle source

Formulario de creación de nuevo fichero adjunto

# File app/controllers/sadmin/attachments_controller.rb, line 29
def new
  @attachment = @attachable.attachments.new
  @title = t('sadmin.create_what', :what => Attachment.human_name)
end
update() click to toggle source

Actualización de los atributos de un fichero

# File app/controllers/sadmin/attachments_controller.rb, line 52
def update
  #@attachment = Attachment.find(params[:id])
  if @attachment.update_attributes(params[:attachment])
    flash[:notice] = t('sadmin.guardado_correctamente', :article => @attachment.class.human_name.gender_article, :what => @attachment.class.human_name)
    redirect_to sadmin_document_page_url(@attachment.attachable)
  else
    render :action => "edit"
  end    
end