themen fix + remote form für themen

This commit is contained in:
Andreas Stephanides
2014-02-07 22:15:05 +01:00
parent 35cc371d22
commit 48fc0455c7
9 changed files with 41 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
class FragenController < ApplicationController
# GET /fragen
# GET /fragen.json
@@ -42,14 +43,16 @@ class FragenController < ApplicationController
# POST /fragen.json
def create
@frage = Frage.new(params[:frage])
@fragen=@frage.thema.fragen
respond_to do |format|
if @frage.save
format.html { redirect_to @frage.thema, notice: 'Frage was successfully created.' }
format.json { render json: @frage, status: :created, location: @frage }
format.js
else
format.html { render action: "new" }
format.json { render json: @frage.errors, status: :unprocessable_entity }
format.js
end
end
end
@@ -74,11 +77,16 @@ class FragenController < ApplicationController
# DELETE /fragen/1.json
def destroy
@frage = Frage.find(params[:id])
@thema=@frage.thema
@frage.destroy
respond_to do |format|
format.html { redirect_to @frage.thema }
format.json { head :no_content }
format.js {
@fragen=@thema.fragen
render :create
}
end
end
end

View File

@@ -16,6 +16,7 @@ class ThemenController < ApplicationController
# GET /themen/1.json
def show
@thema = Thema.find(params[:id])
@fragen=@thema.fragen
@toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>edit_thema_path(@thema)}]
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('thema.remove'), :path=>thema_path(@thema), :method=>:delete, :confirm=>I18n.t('thema.sure')}

View File

@@ -16,9 +16,10 @@ class ThemengruppenController < ApplicationController
# GET /themengruppen/1.json
def show
@themengruppe = Themengruppe.find(params[:id])
@toolbar_elements = [{:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('thema.add'), :path=>new_themengruppe_thema_path(@themengruppe)}]
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('themengruppe.edit'), :path=>edit_themengruppe_path(@themengruppe)}
@toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')}
@toolbar_elements = []
@toolbar_elements << {:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('thema.add'), :path=>new_themengruppe_thema_path(@themengruppe)} if can? :new, Themengruppe
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('themengruppe.edit'), :path=>edit_themengruppe_path(@themengruppe)} if can? :edit, @themengruppe
@toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')} if can? :delete, @themengruppe
respond_to do |format|