请参阅我对上一篇文章的回答。这将为您提供一个在Rails中的AJAX想法:完成模型#更新后显示模型#新表单
您可以做的是在操作中呈现一个json并将部分作为json传递。
def mostrecent @school = School.find_by_slug(request.url.gsub('http://localhost:3000/','')).id @microposts = @user.microposts.order('created_at DESC').paginate(:per_page => 3, :page => params[:page]) respond_to do |format| format.json { render :json => {:success => true, :html => (render_to_string 'users/microposts')} } format.html { } endend您可以访问js中的json(即javascript /coffeescript文件,例如mostrecent.js或mostrecent.js.coffee)并替换当前元素。
$('.TabText').live 'ajax:success', (event,data) -> $('#ContentBody').html(data.html) if(data.success == true)


