From 7494e767011fc3b47f62dee6e730218c388ac9a7 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Thu, 21 Mar 2013 20:17:30 +0100 Subject: [PATCH] Controller Update --- app/controllers/moduls_controller.rb | 2 +- app/controllers/studien_controller.rb | 27 +++++++++++++++------------ config/locales/de.yml | 1 + 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/controllers/moduls_controller.rb b/app/controllers/moduls_controller.rb index 689a71e..33aead5 100644 --- a/app/controllers/moduls_controller.rb +++ b/app/controllers/moduls_controller.rb @@ -68,7 +68,7 @@ class ModulsController < ApplicationController respond_to do |format| if @modul.update_attributes(params[:modul]) - format.html { redirect_to modul_path(@modul), notice: 'Modul was successfully updated.' } + format.html { redirect_to url_for(@modul), notice: 'Modul was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } diff --git a/app/controllers/studien_controller.rb b/app/controllers/studien_controller.rb index e183165..9878b4e 100644 --- a/app/controllers/studien_controller.rb +++ b/app/controllers/studien_controller.rb @@ -18,11 +18,14 @@ class StudienController < ApplicationController opts={:width=>4, :slice=>3} end modulgruppen =[] - modulgruppen_phase.each_slice(opts[:slice]) do |s| modulgruppen<modulgruppen, :phase => ph}.merge(opts) - @toolbar_elements=[{:text => ' '.html_safe + I18n.t('studien.new') , :path => new_modul_path() }] - @toolbar_elements<<{:text => ' '.html_safe + I18n.t('common.edit'),:path=>edit_studium_path(@studium)} - #@toolbar_elements<<{:text =' '.html_safe +I18n.t('common.delete'),path => delete_studium_path(@studium)} + modulgruppen_phase.each_slice(opts[:slice]) do |s| + modulgruppen<modulgruppen, :phase => ph}.merge(opts) + + @toolbar_elements=[{:text => ' '.html_safe + I18n.t('studien.new') , :path => new_studium_modulgruppe_path(@studium) }] + @toolbar_elements<<{:text => ' '.html_safe + I18n.t('common.edit'),:path=>edit_studium_path(@studium)} + @toolbar_elements<<{:link=> link_to('Destroy', @studium, method: :delete, data: { confirm: 'Are you sure?' })} end end @@ -33,6 +36,8 @@ class StudienController < ApplicationController # GET /studia/1/edit 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 # POST /studia @@ -42,11 +47,9 @@ class StudienController < ApplicationController respond_to do |format| if @studium.save - format.html { redirect_to @studium, notice: 'Studium was successfully created.' } - format.json { render json: @studium, status: :created, location: @studium } + format.html { redirect_to url_for(@studium), notice: 'Studium was successfully created.' } else format.html { render action: "new" } - format.json { render json: @studium.errors, status: :unprocessable_entity } end end end @@ -57,7 +60,7 @@ class StudienController < ApplicationController respond_to do |format| if @studium.update_attributes(params[:studium]) - format.html { redirect_to @studium, notice: 'Studium was successfully updated.' } + format.html { redirect_to url_for(@studium), notice: 'Studium was successfully updated.' } else format.html { render action: "edit" } @@ -69,8 +72,8 @@ class StudienController < ApplicationController # DELETE /studia/1 # DELETE /studia/1.json def destroy - @studium = Studium.find(params[:id]) - @studium.destroy -redirect_to studien_url + @studium = Studium.find(params[:id]) + @studium.destroy + redirect_to studien_url end end diff --git a/config/locales/de.yml b/config/locales/de.yml index a421184..f2135a5 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -7,6 +7,7 @@ de: actions: "Aktionen" studien: list: "Studien der Fakultät Elektrotechnik" + anzeigen: "Studium anzeigen" new: "Neues Studium" newmodulgroup: "Neue Modulgruppe" allestudien: "Alle Studien"