forked from bofh/fetsite
AutoCommit Sam Aug 1 11:03:01 CEST 2015
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
class CommentsController < ApplicationController
|
class CommentsController < ApplicationController
|
||||||
|
before_filter :decode_commentable_type
|
||||||
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?
|
||||||
num = {"Beispiel"=> 2, "Survey::Question"=> 7}
|
num = {"Beispiel"=> 2, "Survey::Question"=> 7}
|
||||||
@@ -96,4 +97,9 @@ num = {"Beispiel"=> 2, "Survey::Question"=> 7}
|
|||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
private
|
||||||
|
def decode_commentable_type
|
||||||
|
params[:commentable_type].gsub("_","::")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,9 @@
|
|||||||
module CommentsHelper
|
module CommentsHelper
|
||||||
|
def wrapid_for(o)
|
||||||
|
divid_for(o,"comments")
|
||||||
|
end
|
||||||
|
def render_comments_for(o)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
11
app/helpers/plugins_helper.rb
Normal file
11
app/helpers/plugins_helper.rb
Normal file
@@ -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
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<%= render @survey_question %>
|
<%= 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 "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) %>
|
||||||
<div id="<%= Comment.formid_for( @survey_question) %>">
|
<div id="<%= Comment.formid_for( @survey_question) %>">
|
||||||
</div>
|
</div>
|
||||||
<% unless @survey_question.comments.roots.empty? %>
|
<% unless @survey_question.comments.roots.empty? %>
|
||||||
|
|||||||
Reference in New Issue
Block a user