【问题标题】:How do I use formtastic to create a remote form using acts_as_commentable in Rails 3?如何使用 formtastic 在 Rails 3 中使用acts_as_commentable 创建远程表单?
【发布时间】:2011-04-20 05:23:31
【问题描述】:

我正在使用acts_as_commentable。这就是模型添加 cmets 的方式:

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

可以在此处找到宝石的详细信息:

https://github.com/jackdempsey/acts_as_commentable

在 formtastic 中,我通常会传递模型,然后是输入字段....这仍然有效吗?

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

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

在控制器中....?

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

我不确定这是否会传递可用的哈希值....谢谢!

【问题讨论】:

  • 哦,是的,我想我也希望它提交远程....。

标签: ruby-on-rails forms formtastic acts-as-commentable


【解决方案1】:

是的,这应该可以。你试过了吗?

就像 Rails 的 form_for 一样,您可以为远程表单传入 :remote =&gt; true 选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多