Rails Rails Ajax 的一个小问题

bpw11320 · November 15, 2013 · Last by miclle replied at November 15, 2013 · 1975 hits

完全新手的问题,求大神解答下。 有一个 TuansController 里面定义了一个 apply_rollcalls 的方法,希望通过 form_for ajax 的方式提交到后台。 form 里面分别有三个参数 tuan_id、name、phone,tuan_id 是 hidden 的方式,并且赋值的,请教下 这个 form_for 要该怎么写的呢?ruoutes 里面要该如何配置呢?

还有一个问题是。 如果不使用 form_for ajax 的这种方式提交 ajax,完全使用 js 去提交,有没有什么好的方式可以介绍的。

application.js

//= require jquery
//= require jquery_ujs

erb

form_for @xxx, :remote => true

routes

resources :tuans do
  post :apply_rollcalls #:on => :member /:collection
end
You need to Sign in before reply, if you don't have an account, please Sign up first.