# class StudienController

### Public Instance Methods

create() click to toggle source

    # File controllers/studien_controller.rb, line 44
    def create
      @studium = Studium.new(params[:studium])
      respond_to do |format|
        if @studium.save
          format.html { redirect_to url_for(@studium), notice: 'Studium was successfully created.' }
        else
          format.html { render action: "new" }
        end
      end
    end

destroy() click to toggle source

    # File controllers/studien_controller.rb, line 68
    def destroy
          @studium = Studium.find(params[:id])
          @studium.destroy
          redirect_to studien_url
    end

edit() click to toggle source

    # File controllers/studien_controller.rb, line 38
    def edit
      @studium = Studium.find(params[:id])
          @toolbar_elements=[{:text => I18n.t('studien.anzeigen') , :path => url_for(@studium) }]
          @toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)}
    end

index() click to toggle source

    # File controllers/studien_controller.rb, line 5
     def index
       @studien = Studium.all
       @toolbar_elements<<{:icon =>:plus, :text=> I18n.t('studien.new') ,:path=>new_studium_path }
    end

new() click to toggle source

    # File controllers/studien_controller.rb, line 34
    def new
      @studium = Studium.new
    end

show() click to toggle source

    # File controllers/studien_controller.rb, line 10
     def show
       @studium= Studium.find(params[:id])
       @studienphasen=[]
       [1, 2 ,3].each do |ph|
           modulgruppen_phase=@studium.modulgruppen.where(:phase=>ph)
           if modulgruppen_phase.count==1
                   opts={:width=>12, :slice=>1}
           elsif modulgruppen_phase.count <= 4
                   opts={:width=>6, :slice=>2}
           else
                   opts={:width=>4, :slice=>3}
           end
           modulgruppen =[]
           modulgruppen_phase.each_slice(opts[:slice]) do |s|
           modulgruppen<<s
           end
           @studienphasen << {:modulgruppen=>modulgruppen, :phase => ph}.merge(opts)
       end
       @toolbar_elements=[{:icon =>:plus ,:text=> I18n.t('studien.new') , :path => new_studium_modulgruppe_path(@studium) }]
       @toolbar_elements<<{:icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_studium_path(@studium)}
       @toolbar_elements<<{:text=> I18n.t('common.delete'),:path => studium_path(@studium), :method=> :delete,:confirm=>"Sure?" }
    end

update() click to toggle source

    # File controllers/studien_controller.rb, line 56
    def update
      @studium = Studium.find(params[:id])

        if @studium.update_attributes(params[:studium])
           redirect_to url_for(@studium), notice: 'Studium was successfully updated.'
        else
           render action: "edit"

        end

    end