English 中文(简体)
字段(_F),用于造成过滤器链阻止错误(_F)
原标题:fields_for causing a filter chain halted error

我试图为事件记录创建一个新的事件选项。 我设置了“ 事件”, 以接受: event_ places 和 在我看来的以下代码 :

<div id="add_venue_form" style="border:2px solid black; padding: 5px;">
<% form_for @event, :html => {:name => "form2"} do |f| -%>
    <% f.fields_for @event_place do |v| -%>
      <%= v.text_field :place_id %>
    <% end -%>
    <a class="button" style="margin-left:10px;margin-top:4px;" href="javascript:document.form2.submit();" onclick="this.blur();"><span>Save</span></a>

<% end -%>

当我在字段中添加一个代号并单击保存按钮时,它给了我这个错误:

Processing EventController#update (for 127.0.0.1 at 2012-05-24 15:43:39) [PUT]
Parameters: {"id"=>"48404", "action"=>"update", "controller"=>"event", 
    "_method"=>"put", "event"=>{"event_place"=>{"place_id"=>"3"}}}
SQL (0.1ms)   SET NAMES UTF8
Redirected to http://localhost:3001/event/list
Filter chain halted as [#<Proc:0x00000001094746e0@/Users/anthonylassiter/.rbenv/versions/ree-1.8.7 2012.02/lib/ruby/gems/1.8/gems/actionpack-2.3.10/lib/action_controller/verification.rb:82>] rendered_or_redirected.
Completed in 8ms (DB: 0) | 302 Found [http://localhost/events/48404]

我的更新方法

 def update
     @event = Event.find(params[:id])
     if @event.update_attributes(params[:event])
       redirect_to index
     end
 end

看起来参数是正确的。 它似乎甚至没有在我的事件控制器上击中我的更新方法, 而是造成一些内部错误, 并试图重定向到不存在的 / 列表中, 但是如果更新有效, 我不需要这样做 。

最佳回答

在您的控制器( 或其超级类之一) 的某处, 您正在使用 < code> 验证 来限制可以提出的要求( 或者您正在使用的插件可以叫作校验 ) 。 登入的请求失败了其中的一个校验步骤, 因此铁路改道了 。

问题回答

参数不正确, 您的参数中必须有 r event_ places_ attribittes ... try 并在字段中使用 :event_places





相关问题
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: ...

热门标签