| Class | Sadmin::AttachmentsController |
| In: |
app/controllers/sadmin/attachments_controller.rb
|
| Parent: | Sadmin::BaseController |
Creación de nuevo fichero adjunto
# File app/controllers/sadmin/attachments_controller.rb, line 15
15: def create
16: @attachment = @document.send(params[:t].pluralize).new({:type => params[:t]}.merge(params[:attachment]))
17: if @attachment.save
18: flash[:notice] = t('sadmin.guardado_correctamente', :article => params[:t].camelize.constantize.human_name.gender_article, :what => params[:t].camelize.constantize.human_name)
19: redirect_to sadmin_document_page_url(@document)
20: else
21: render :action => "new"
22: end
23: end
Eliminación de un fichero
# File app/controllers/sadmin/attachments_controller.rb, line 43
43: def destroy
44: #@attachment = Attachment.find(params[:id])
45: if @attachment.destroy
46: flash[:notice] = t('sadmin.eliminado_correctamente', :article => @attachment.class.human_name.gender_article, :what => @attachment.class.human_name)
47: else
48: flash[:error] = t('sadmin.no_eliminado_correctamente', :article => @attachment.class.human_name.gender_article, :what => @attachment.class.human_name)
49: end
50: redirect_to sadmin_document_page_url(@attachment.document)
51: end
Modificación de los atributos de un fichero
# File app/controllers/sadmin/attachments_controller.rb, line 26
26: def edit
27: #@attachment = Attachment.find(params[:id])
28: @title = t('sadmin.modificar_what', :what => @attachment.class.human_name)
29: end
Formulario de creación de nuevo fichero adjunto
# File app/controllers/sadmin/attachments_controller.rb, line 9
9: def new
10: @attachment = @document.send(params[:t].pluralize).new(:type => params[:t])
11: @title = t('sadmin.create_what', :what => params[:t].camelize.constantize.human_name)
12: end
Actualización de los atributos de un fichero
# File app/controllers/sadmin/attachments_controller.rb, line 32
32: def update
33: #@attachment = Attachment.find(params[:id])
34: if @attachment.update_attributes(params[:attachment])
35: flash[:notice] = t('sadmin.guardado_correctamente', :article => @attachment.class.human_name.gender_article, :what => @attachment.class.human_name)
36: redirect_to sadmin_document_page_url(@attachment.document)
37: else
38: render :action => "edit"
39: end
40: end