search for: find_commentable

Displaying 3 results from an estimated 3 matches for "find_commentable".

2010 Sep 17
25
Trying to look up comment through an ID, but failing
I am trying to allow users to reply through comments by allowing users to click a reply link next to the parent comment. It will send in a parameter to the ''new'' comment view, like so: | <%= link_to "Reply", new_comment_path(:in_reply_to => comment.id) %> The form will use the :in_reply_to parameter in order to save that id as the parent id, like so:
2013 Feb 28
2
Create polymorphic resources
...r Foo/Bar? If it is a comment for a Foo resource, I need to do: @commentable = Foo.find(params[:foo_id]) @commentable.comments.create(....) But if it''s Bar I need to do: @commentable = Bar.find(params[:bar_id]) @commentable.comments.create(....) What I do now is to use this method: def find_commentable params.each do |name, value| if name =~ /(.+)_id$/ return $1.classify.constantize.find(value) end end nil end and @commentable = find_commentable Which loops over all params for something that ends with _id and then get the class name from that etc... But that feels a bit &...
2010 Sep 11
10
Having difficulty with threaded comments, using acts_as_tree
...find(params[:id]) @commentable = Article.find(params[:id]) @comments = @commentable.comments # @comments = @commentable.comments.paginate(:page => params[:page]) @comment = Comment.new @title = @article.title end Here is my comments controller: def show @commentable = find_commentable @comment = @commentable.comments.find(params[:id]) # @comments = @commentable.comments.paginate(:page => params[:page]) end def new @commentable = find_commentable @comment = Comment.new end def create @commentable = find_commentable if @comment.commentable_type...