From a079a88dbc3911f7e01b944c2ec98020f8880c8e Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sat, 1 Aug 2015 11:03:01 +0200 Subject: [PATCH] AutoCommit Sam Aug 1 11:03:01 CEST 2015 --- app/controllers/comments_controller.rb | 6 ++++++ app/helpers/comments_helper.rb | 7 +++++++ app/helpers/plugins_helper.rb | 11 +++++++++++ app/views/survey/questions/show.html.erb | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/helpers/plugins_helper.rb diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index a5007e6..eff788b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,4 +1,5 @@ class CommentsController < ApplicationController +before_filter :decode_commentable_type def index @commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil? num = {"Beispiel"=> 2, "Survey::Question"=> 7} @@ -96,4 +97,9 @@ num = {"Beispiel"=> 2, "Survey::Question"=> 7} format.js end end +private +def decode_commentable_type + params[:commentable_type].gsub("_","::") +end + end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 0ec9ca5..2706ddb 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -1,2 +1,9 @@ module CommentsHelper + def wrapid_for(o) + divid_for(o,"comments") + end + def render_comments_for(o) + + + end end diff --git a/app/helpers/plugins_helper.rb b/app/helpers/plugins_helper.rb new file mode 100644 index 0000000..71e048b --- /dev/null +++ b/app/helpers/plugins_helper.rb @@ -0,0 +1,11 @@ +module PluginsHelper + def divid_for(object,suffix="") + if object.nil? + "" + else + object.class.to_s.to_lower.gsub("::","_")+ suffix.to_lower + object.id.to_s + end + end + +end +o diff --git a/app/views/survey/questions/show.html.erb b/app/views/survey/questions/show.html.erb index 21d4d6a..4c05a31 100644 --- a/app/views/survey/questions/show.html.erb +++ b/app/views/survey/questions/show.html.erb @@ -7,7 +7,7 @@ <%= render @survey_question %> <%= link_to "comment" , new_comment_path( commentable_type: "Survey::Question", commentable_id: @survey_question.id), remote:true if can? :comment, @survey_question %> -<%= link_to "comments:.."+ @survey_question.comments.count().to_s, comments_path(commentable_type: "Survey::Question", commentable_id: @survey_question.id), remote:true, id: Comment.switchshowid_for( @survey_question) %> +<%= link_to "comments:.."+ @survey_question.comments.count().to_s, comments_path(commentable_type: "Survey_Question", commentable_id: @survey_question.id), remote:true, id: Comment.switchshowid_for( @survey_question) %>
<% unless @survey_question.comments.roots.empty? %>