开发者

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/开发者_JS百科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!


Yes, this should work. Did you try it?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜