try to fix the thing i suggested in red and add a parent_id field to the
comments table,
then make a self referencial associaction or use the acts_as_tree gem, the
thing is along with
the polimorphic fields a comment should be able to belong to another
comment, when you try to make a comment
belong to another comment with the same association you are using for when
it belongs to article or anything else
the migration to that polymorphic parent is lost, why ? because you are
using this function
def find_commentable
params.each do |name, value|
if name =~ /(.+)_id$/
return $1.classify.constantize.find(value)
end
end
nilend
with it you are trying to find what comments owns the new comment that was
added as a chils.
but this
~ /(.+)_id$/
pulls from the params hash, the params hash passes the model that has
comments nested not the
comment want to attach your new comment to.
also you are calling new on something that will call new again, that is when
you check with new to build the child
is tries to see who the parent is but you mistankenly pass the same object.
if need more details on how to fix all this, i can try to help, but as you
notice my english is far from perfect.
here is how the acts_as_tree gem works
http://railscasts.com/episodes/162-tree-based-navigation
On Tue, Sep 14, 2010 at 3:58 PM, Kelp Kelp <[email protected]> wrote:
> radhames brito wrote:
> > you site crashed because the comment on the page article are found by
> > pulling the article_id from the params but you want to add childrens to
> > a
> > comment and there is no way to pull that id with the find_commentable
> > function
>
> I am having trouble following you. I have to use the polymorphic
> association because my comments will be found on the Article, Profile,
> and Picture models.
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.