2010-12-08 41 views
0

我有一个notes模型,它与users模型有多对多的关系。在notes控制器索引视图我有这样的形式:试图提交表单时奇怪的导轨行为

<form id='note_form' method="post" action="/notes/temp_path" > 
    <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />   
    <input type="text" size="30" name="start_date" id="start_date"> 
</form> 

指向在notes控制器temp_path动作。出于某种原因,当提交此表单时,Rails不会运行temp_path操作中的代码,而是尝试加载某个音符,并且因为它不能,所以它会重定向回索引。

Started POST "/notes/temp_path" for 127.0.0.1 at 2010-12-08 22:08:25 +1000 
DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead. (called from <class:ApplicationController> at /Users/ben/rails_projects/note_prog/app/controllers/application_controller.rb:6) 
    Processing by NotesController#temp_path as HTML 
    Parameters: {"authenticity_token"=>"Ck6NmmYO86rvJSEsiqpIMkcaiErEhV7s/XMzjka15AI="} 
    User Load (0.3ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 56) LIMIT 1 
    UserNote Load (0.2ms) SELECT "user_notes".* FROM "user_notes" WHERE ("user_notes"."note_id" = 0) 
Redirected to http://localhost:3000/notes 

我很肯定WHERE ("user_notes"."note_id" = 0)位是造成这个问题。但我不知道为什么这样做甚至正在完成?基于上面的代码,User Load (0.3ms) SELECT "users".* ...它看起来像是幕后Rails的东西。在temp_path动作中,无处需要加载现有的音符。我怎样才能阻止呢?我正在使用Rails 3.0.1。谢谢阅读。

回答

1

你应该告诉我们你的控制器的代码。你有没有'redirect_to'语句?有任何条件?

也许你在你的控制器中有一些过滤器,也许在ApplicationController中?从弃用警告中,我发现您可能有一些代码。