diff --git a/app/controllers/fragen_controller.rb b/app/controllers/fragen_controller.rb
index cac35da..8e0eddc 100644
--- a/app/controllers/fragen_controller.rb
+++ b/app/controllers/fragen_controller.rb
@@ -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
diff --git a/app/controllers/themen_controller.rb b/app/controllers/themen_controller.rb
index 118a586..51a24dc 100644
--- a/app/controllers/themen_controller.rb
+++ b/app/controllers/themen_controller.rb
@@ -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')}
diff --git a/app/controllers/themengruppen_controller.rb b/app/controllers/themengruppen_controller.rb
index daa296d..29ada1f 100644
--- a/app/controllers/themengruppen_controller.rb
+++ b/app/controllers/themengruppen_controller.rb
@@ -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|
diff --git a/app/views/fragen/_frage.html.erb b/app/views/fragen/_frage.html.erb
index 5b9e67a..1fbc55a 100644
--- a/app/views/fragen/_frage.html.erb
+++ b/app/views/fragen/_frage.html.erb
@@ -4,5 +4,5 @@
<%= link_to 'Edit', edit_frage_path(frage) %> |
-<%= link_to 'Destroy',frage, method: :delete, data: { confirm: 'Are you sure?' } %>
+<%= link_to 'Destroy',frage, method: :delete, :remote=> true , data: { confirm: 'Are you sure?' } %>