Creating an AJAX Form for a Polymorphic Object in Rails

Posted by Isaac Yerushalmi on Stack Overflow See other posts from Stack Overflow or by Isaac Yerushalmi
Published on 2010-12-25T21:50:30Z Indexed on 2010/12/25 21:54 UTC
Read the original article Hit count: 213

I am trying to create an AJAX form for a polymorphic associated model.

I created "Comments" which have a polymorphic association with all objects you can comment on (i.e. user profiles, organization profiles, events, etc).

I can currently add comments to objects using a form created by:

form_for [@commentable, @comment] do |f|

I am trying to make this form via Ajax but I keep getting errors.

I've tried at least ten different pieces of code, using remote_form_tag, remote_form_for, etc..with all different options, and nothing works. The comment does not get inserted into the database.

Can anyone please tell me how I can make the above form ajax-enabled?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about polymorphic-associations