English 中文(简体)
从表格中转至远程格式,用于提交铁路变化的问题
原标题:Switching from form_for to remote_form_for problems with submit changes in Rails

还有一天与铁路连接,今天,我想使用Ajax.链接_remote_link,来改变案文,是非常容易的,因此,我认为,改用我的形式也很容易——只用一个有边远的Ajax申请表。 表格_for,但偏僻问题 形式——因为它没有拯救我的变化?

这里使用的守则:

<% form_for bill, :url => {:action =>  update , :id => bill.id} do |f| %>
# make the processing e.g. displaying texfields and so on
<%= submit_tag  speichern %>

它制定了以下《html法典》:

<form action="/adminbill/update/58" class="edit_bill" id="edit_bill_58" method="post"><div style="margin:0;padding:0;display:inline"><input name="_method" type="hidden" value="put" /></div>
<!-- here the html things for the forms -->
<input class="button" name="commit" type="submit" value="speichern" />

在这里,这部法律没有给我带来变化并提交:

<% remote_form_for bill, :url => {:action =>  update , :id => bill.id} do |f| %>
# make the processing e.g. displaying texfields and so on
<%= submit_tag  speichern %>

它制定了以下《html法典》:

<form action="/adminbill/update/58" class="edit_bill" id="edit_bill_58" method="post" onsubmit="$.ajax({data:$.param($(this).serializeArray()), dataType: script , type: post , url: /adminbill/update/58 }); return false;"><div style="margin:0;padding:0;display:inline"><input name="_method" type="hidden" value="put" /></div>
<!-- here the html things for the forms -->
<input class="button" name="commit" type="submit" value="speichern" />

我不知道我是否在使用遥远的图像(见?remote_form_for)时需要考虑一些特殊问题。

最佳回答

引言

<% remote_form_for :bill, bill, :url => {:action =>  update , :id => bill.id} do |f| %>

页: 1

<% remote_form_for bill, bill, :url => {:action =>  update , :id => bill.id} do |f| %>

EDITED。

我认为,你的回答是个问题,你们的更新方法应该像以下那样:

def update
  @bill = Bill.find(params[:id])
  if  @bill.update_attributes(params[:bill])
    render :update |page|
      page.replace_html "some_div", :partial=> some_partial , :object=>[@bill]
      page.replace_html "notice_div", "Bill updated succesfully"
    end
  else
    render :update |page|
      page.replace_html "some_div", :partial=> some_partial , :object=>[@bill]
      page.replace_html "notice_div", ""
    end
  end
end
问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签