AutoCommit Son Aug 2 15:03:01 CEST 2015
This commit is contained in:
@@ -4,11 +4,9 @@ class CommentsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
||||||
@comments=@commentable.comments.order(:created_at).roots.accessible_by(current_ability, :show).page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
@comments=@commentable.comments.order(:created_at).roots.accessible_by(current_ability, :show).page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
def hide
|
def hide
|
||||||
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
||||||
@@ -62,18 +60,14 @@ class CommentsController < ApplicationController
|
|||||||
# PUT /comments/1
|
# PUT /comments/1
|
||||||
# PUT /comments/1.json
|
# PUT /comments/1.json
|
||||||
def update
|
def update
|
||||||
|
|
||||||
params[:comment].select! {|i| !["commentable_id", "commentable_type"].include?(i)}
|
params[:comment].select! {|i| !["commentable_id", "commentable_type"].include?(i)}
|
||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
@comment.commentable=params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
|
@comment.commentable=params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
if @comment.update_attributes(params[:comment])
|
if @comment.update_attributes(params[:comment])
|
||||||
format.html { redirect_to @comment.commentable, notice: 'Comment was successfully updated.' }
|
format.html { redirect_to @comment.commentable, notice: 'Comment was successfully updated.' }
|
||||||
format.json { head :no_content }
|
|
||||||
else
|
else
|
||||||
format.html { render action: "edit" }
|
format.html { render action: "edit" }
|
||||||
format.json { render json: @comment.errors, status: :unprocessable_entity }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -86,13 +80,12 @@ class CommentsController < ApplicationController
|
|||||||
@comment.destroy
|
@comment.destroy
|
||||||
@comments=@commentable.comments.order(:created_at).roots.page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
@comments=@commentable.comments.order(:created_at).roots.page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private
|
private
|
||||||
def decode_commentable_type
|
def decode_commentable_type
|
||||||
params[:commentable_type].gsub!("_","::") unless params[:commentable_type].nil?
|
params[:commentable_type].gsub!("_","::") unless params[:commentable_type].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
@survey_questions = Survey::Question.all
|
@survey_questions = Survey::Question.all
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.json { render json: @survey_questions }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def answer
|
def answer
|
||||||
@@ -34,7 +33,6 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # show.html.erb
|
format.html # show.html.erb
|
||||||
format.json { render json: @survey_question }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,10 +40,8 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
# GET /survey/questions/new.json
|
# GET /survey/questions/new.json
|
||||||
def new
|
def new
|
||||||
@survey_question = Survey::Question.new
|
@survey_question = Survey::Question.new
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # new.html.erb
|
format.html # new.html.erb
|
||||||
format.json { render json: @survey_question }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,10 +58,8 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @survey_question.save
|
if @survey_question.save
|
||||||
format.html { redirect_to @survey_question, notice: 'Question was successfully created.' }
|
format.html { redirect_to @survey_question, notice: 'Question was successfully created.' }
|
||||||
format.json { render json: @survey_question, status: :created, location: @survey_question }
|
|
||||||
else
|
else
|
||||||
format.html { render action: "new" }
|
format.html { render action: "new" }
|
||||||
format.json { render json: @survey_question.errors, status: :unprocessable_entity }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -78,10 +72,8 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @survey_question.update_attributes(params[:survey_question])
|
if @survey_question.update_attributes(params[:survey_question])
|
||||||
format.html { redirect_to @survey_question, notice: 'Question was successfully updated.' }
|
format.html { redirect_to @survey_question, notice: 'Question was successfully updated.' }
|
||||||
format.json { head :no_content }
|
|
||||||
else
|
else
|
||||||
format.html { render action: "edit" }
|
format.html { render action: "edit" }
|
||||||
format.json { render json: @survey_question.errors, status: :unprocessable_entity }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -94,7 +86,7 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to survey_questions_url }
|
format.html { redirect_to survey_questions_url }
|
||||||
format.json { head :no_content }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
$("#<%= Comment.wrapid_for(@commentable) %>").html("<%= escape_javascript "" %>")
|
$("#<%= Comment.wrapid_for(@commentable) %>").html("<%= escape_javascript "" %>")
|
||||||
|
|
||||||
$("#<%= Comment.switchshowid_for(@commentable) %>").attr("href","<%= escape_javascript comments_path(commentable_type: @commentable.class.to_s, commentable_id: @commentable.id) %>")
|
$("#<%= Comment.switchshowid_for(@commentable) %>").replaceWith("<%= escape_javascript link_to "Comments...", comments_path(commentable_type: @commentable.class.to_s, commentable_id: @commentable.id) %>")
|
||||||
|
|||||||
Reference in New Issue
Block a user