Class | Admin::MaterialsController
In: | app/controllers/admin/materials_controller.rb
Parent: | Admin::BaseController

### Methods

create destroy edit index new show update

### Public Instance methods

create()

[Source]

        # File app/controllers/admin/materials_controller.rb, line 22
    22:   def create
    23:     @material = Material.new(params[:material])
    24:     if @material.save
    25:       flash[:notice] = 'El fichero se ha guardado correctamente'
    26:       redirect_to admin_materials_path
    27:     else
    28:       render :action => 'new'
    29:     end
    30:   end

destroy()

[Source]

        # File app/controllers/admin/materials_controller.rb, line 42
    42:   def destroy
    43:     @material = Material.find(params[:id])
    44:     if @material.destroy
    45:       flash[:notice] = 'El fichero se ha eliminado correctamente'
    46:       redirect_to admin_materials_path
    47:     else
    48:       flash[:error] = 'El fichero no se ha podido eliminar'
    49:       redirect_to admin_material_path(@material)
    50:     end
    51:   end

edit()

[Source]

        # File app/controllers/admin/materials_controller.rb, line 17
    17:   def edit
    18:     @material = Material.find(params[:id])
    19:     @title = 'Modificar fichero'
    20:   end

index()

[Source]

       # File app/controllers/admin/materials_controller.rb, line 2
    2:   def index
    3:     @title = 'Ficheros'
    4:     @materials = Material.paginate :page => params[:page], :order => "title"
    5:   end

new()

[Source]

        # File app/controllers/admin/materials_controller.rb, line 12
    12:   def new
    13:     @material = Material.new
    14:     @title = 'Nuevo fichero'
    15:   end

show()

[Source]

        # File app/controllers/admin/materials_controller.rb, line 7
     7:   def show
     8:     @material = Material.find(params[:id])
     9:     @title = @material.title
    10:   end

update()

[Source]

        # File app/controllers/admin/materials_controller.rb, line 32
    32:   def update
    33:     @material = Material.find(params[:id])
    34:     if @material.update_attributes(params[:material])
    35:       flash[:notice] = 'El fichero se ha guardado correctamente'
    36:       redirect_to admin_material_path(@material)
    37:     else
    38:       render :action => 'edit'
    39:     end
    40:   end

[Validate]