私はREMOTE_FORM_FORがあなたの必要と思うものです。
例:あなたのビューで
:
<%- remote_form_for(comment, :url => topic_post_comments_path(@topic, post),
:after => "submitComment(self);$('input').disable()") do |f| %>
<%= f.text_field :body, :size => 70, :class => "comment_body" %><br />
<%= f.submit "Submit", :class => "comment_submit" %>
<%- end -%>
お知らせ:javascript関数に:後のjavascript機能の私の習慣です。あなたはremote_form_forのためのいくつかの感触を取得した後
そして、あなたのコントローラで(それはここではcomments_controllerです)
@comment = @post.comments.new params[:comment] # actually, it depends on your model :p
respond_to do |format|
# remember to handle exception here. like if @comment.save or not
format.html
format.js {
render :update do |page|
pagepage.visual_effect :highlight, "comments"
end
}
end
とにかくそれだけで簡単にサンプルだ、あなたはより多くの詳細を処理しなければなりません。
幸運。
これは、このform_remote_forが依存するコード部分を指定した場合に役立ちます。また、form_remote_for自体と使用しているrjs部分。 – Petros