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。謝謝閱讀。