diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 40494fa..7fcb94b 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -32,6 +32,7 @@ class AttachmentsController < ApplicationController
respond_to do |format|
format.html # new.html.erb
format.json { render json: @attachment }
+ format.js
end
end
@@ -46,15 +47,17 @@ class AttachmentsController < ApplicationController
def create
@attachment = Attachment.new(params[:attachment])
@thema = Thema.find(params[:thema_id])
- @attachment.thema_id = @thema.id
-
+ @attachment.thema_id = @thema.id
+
respond_to do |format|
if @attachment.save
format.html { redirect_to @thema, notice: 'Attachment was successfully created.' }
format.json { render json: @thema, status: :created, location: @thema }
+ format.js { @attachment = Attachment.new }
else
format.html { render action: "new" }
format.json { render json: @attachment.errors, status: :unprocessable_entity }
+ format.js { render action: "new"}
end
end
end
@@ -69,9 +72,11 @@ class AttachmentsController < ApplicationController
if @attachment.update_attributes(params[:attachment])
format.html { redirect_to @thema, notice: 'Attachment was successfully updated.' }
format.json { head :no_content }
+ format.js {@attachment=Attachment.new; render action:"create"}
else
format.html { render action: "edit" }
format.json { render json: @attachment.errors, status: :unprocessable_entity }
+ format.js { render action: "new"}
end
end
end
diff --git a/app/controllers/fragen_controller.rb b/app/controllers/fragen_controller.rb
index 8e0eddc..223373a 100644
--- a/app/controllers/fragen_controller.rb
+++ b/app/controllers/fragen_controller.rb
@@ -31,28 +31,34 @@ class FragenController < ApplicationController
respond_to do |format|
format.html
format.json { render json: @frage }
+ format.js
end
end
-
+
# GET /fragen/1/edit
def edit
@frage = Frage.find(params[:id])
+ respond_to do |format|
+ format.html
+ format.js {render action: :new}
+ end
end
# POST /fragen
# POST /fragen.json
def create
@frage = Frage.new(params[:frage])
+ thema=@frage.thema
@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
+ format.js {@frage=Frage.new ; @frage.thema=thema}
else
format.html { render action: "new" }
format.json { render json: @frage.errors, status: :unprocessable_entity }
- format.js
+ format.js
end
end
end
@@ -66,9 +72,11 @@ class FragenController < ApplicationController
if @frage.update_attributes(params[:frage])
format.html { redirect_to @frage, notice: 'Frage was successfully updated.' }
format.json { head :no_content }
+ format.js {@frage=Frage.new; render action: "new"}
else
format.html { render action: "edit" }
format.json { render json: @frage.errors, status: :unprocessable_entity }
+ format.js {render action: "edit"}
end
end
end
diff --git a/app/controllers/themen_controller.rb b/app/controllers/themen_controller.rb
index 51a24dc..8a653f2 100644
--- a/app/controllers/themen_controller.rb
+++ b/app/controllers/themen_controller.rb
@@ -40,6 +40,10 @@ class ThemenController < ApplicationController
# GET /themen/1/edit
def edit
@thema = Thema.find(params[:id])
+ respond_to do |format|
+ format.html
+ format.js
+ end
end
# POST /themen
@@ -57,7 +61,13 @@ class ThemenController < ApplicationController
end
end
end
-
+ def fragen
+ @thema = Thema.find(params[:thema_id])
+ @fragen=@thema.fragen
+ respond_to do |format|
+ format.js
+ end
+ end
# PUT /themen/1
# PUT /themen/1.json
def update
@@ -67,9 +77,11 @@ class ThemenController < ApplicationController
if @thema.update_attributes(params[:thema])
format.html { redirect_to @thema, notice: 'Thema was successfully updated.' }
format.json { head :no_content }
+ format.js
else
format.html { render action: "edit" }
format.json { render json: @thema.errors, status: :unprocessable_entity }
+ format.js { render action: "edit" }
end
end
end
diff --git a/app/views/fragen/_frage.html.erb b/app/views/fragen/_frage.html.erb
index 1fbc55a..1197db7 100644
--- a/app/views/fragen/_frage.html.erb
+++ b/app/views/fragen/_frage.html.erb
@@ -3,6 +3,6 @@
<%= raw(frage.text) %>
-<%= link_to 'Edit', edit_frage_path(frage) %> |
+<%= link_to 'Edit', edit_frage_path(frage),:remote=>true %> |
<%= link_to 'Destroy',frage, method: :delete, :remote=> true , data: { confirm: 'Are you sure?' } %>