Search code examples
ruby-on-railsformsformtasticacts-as-commentable

How do I use formtastic to create a remote form using acts_as_commentable in Rails 3?


I am using acts_as_commentable. This is how the Model has comments added to it:

 commentable = Post.create
 commentable.comments.create(:title => "First comment.", :comment => "This is the first comment.")

the gem specifics can be found here:

https://github.com/jackdempsey/acts_as_commentable

In formtastic, I normally would pass the model, and then the input fields....would that still work?

 <%= semantic_form_form 'review' do |form| %>

     <%= form.input :title %>
     <%= form.input :comment %>
 <% end %>

And in the controller....?

  commentable.comments.create(params(:review))

I'm not sure if this would pass the hash that is usable....thanks!


Solution

  • Yes, this should work. Did you try it?

    Just like Rails' form_for, you can pass in a :remote => true option for remote forms.