2011-09-27 44 views
0

所有的形式在我的Rails應用程序不提交的參數甚至到了production.log:一切形式不傳遞參數

Started GET "/countries/afghanistan/edit/" for 41.132.43.55 at Tue Sep 27 03:39:06 -0700 2011 
    Processing by CountriesController#edit as HTML 
    Parameters: {"id"=>"afghanistan"} 
Rendered countries/_form.html.erb (80.2ms) 
Rendered application/_nav.html.erb (2.8ms) 
Rendered countries/edit.html.erb within layouts/application (85.2ms) 
Completed 200 OK in 87ms (Views: 85.6ms | ActiveRecord: 0.5ms) 


Started GET "/countries/afghanistan/" for 41.132.43.55 at Tue Sep 27 03:40:20 -0700 2011 
    Processing by CountriesController#show as HTML 
    Parameters: {"id"=>"afghanistan"} 
Rendered application/_nav.html.erb (3.9ms) 
Rendered countries/show.html.erb within layouts/application (16.7ms) 
Completed 200 OK in 21ms (Views: 15.3ms | ActiveRecord: 2.3ms) 

從編輯動作的,然後提交表單,它直接的演出行動。在我的dev檢查它表明POST請求已被永久移動(301)GET請求:

enter image description here

我不知道也看在這一點什麼。在開發中一切正常,但不在生產中。這裏是我的production.rb

App::Application.configure do 
    config.cache_classes = true 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 
    config.action_dispatch.x_sendfile_header = "X-Sendfile" 
    config.serve_static_assets = false 
    config.i18n.fallbacks = true 

    config.active_support.deprecation = :notify 
    ActionMailer::Base.smtp_settings = { 
    :address    => "smtp.gmail.com", 
    :port     => 587, 
    :user_name   => "***@***.com", 
    :password    => "***", 
    :authentication  => "plain", 
    :enable_starttls_auto => true 
    } 
    config.middleware.use ExceptionNotifier, 
    :email_prefix => "[Exception] ", 
    :sender_address => %{"Exception Notifier" <***@***.com>}, 
    :exception_recipients => %w{***@***.com} 
end 

任何幫助,非常感謝。謝謝!

更新1 這裏的會話#新

<%= form_tag sessions_path do %> 
    <p> 
    <%= label_tag :login, "Email Address" %><br /> 
    <%= text_field_tag :login, params[:login] %> 
    </p> 
    <p> 
    <%= label_tag :password %><br /> 
    <%= password_field_tag :password %> 
    </p> 
    <p><%= submit_tag "Log in" %></p> 
<% end %> 

而這裏的形式另一個問題:

<%= form_for @satellite do |f| %> 
    <%= f.error_messages %> 
    <p> 
    <%= f.label :name %><br /> 
    <%= f.text_field :name %> 
    </p> 
    <p> 
    <% for country in Country.find(:all) %> 
     <%= check_box_tag "satellite[country_ids][]", country.id, @satellite.countries.include?(country) %> 
     <%= label_tag "satellite[country_ids][]", country.name, :for => "satellite[country_ids][]" %><br /> 
    <% end %> 
    </p> 
    <p><%= f.submit %></p> 
<% end %> 

但是就像我說沒有的形式傳遞參數。

更新2 這裏的路線:

edit_current_user  /user/edit(.:format)        {:controller=>"users", :action=>"edit"} 
      signup  /signup(.:format)        {:controller=>"users", :action=>"new"} 
      logout  /logout(.:format)        {:controller=>"sessions", :action=>"destroy"} 
       login  /login(.:format)         {:controller=>"sessions", :action=>"new"} 
      sessions GET /sessions(.:format)        {:controller=>"sessions", :action=>"index"} 
        POST /sessions(.:format)        {:controller=>"sessions", :action=>"create"} 
     new_session GET /sessions/new(.:format)       {:controller=>"sessions", :action=>"new"} 
     edit_session GET /sessions/:id/edit(.:format)      {:controller=>"sessions", :action=>"edit"} 
      session GET /sessions/:id(.:format)       {:controller=>"sessions", :action=>"show"} 
        PUT /sessions/:id(.:format)       {:controller=>"sessions", :action=>"update"} 
        DELETE /sessions/:id(.:format)       {:controller=>"sessions", :action=>"destroy"} 
       users GET /users(.:format)         {:controller=>"users", :action=>"index"} 
        POST /users(.:format)         {:controller=>"users", :action=>"create"} 
      new_user GET /users/new(.:format)        {:controller=>"users", :action=>"new"} 
      edit_user GET /users/:id/edit(.:format)      {:controller=>"users", :action=>"edit"} 
       user GET /users/:id(.:format)        {:controller=>"users", :action=>"show"} 
        PUT /users/:id(.:format)        {:controller=>"users", :action=>"update"} 
        DELETE /users/:id(.:format)        {:controller=>"users", :action=>"destroy"} 
       maps GET /maps(.:format)         {:controller=>"maps", :action=>"index"} 
        POST /maps(.:format)         {:controller=>"maps", :action=>"create"} 
      new_map GET /maps/new(.:format)        {:controller=>"maps", :action=>"new"} 
      edit_map GET /maps/:id/edit(.:format)       {:controller=>"maps", :action=>"edit"} 
       map GET /maps/:id(.:format)        {:controller=>"maps", :action=>"show"} 
        PUT /maps/:id(.:format)        {:controller=>"maps", :action=>"update"} 
        DELETE /maps/:id(.:format)        {:controller=>"maps", :action=>"destroy"} 
    country_channels GET /countries/:country_id/channels(.:format)  {:controller=>"channels", :action=>"index"} 
    country_channel GET /countries/:country_id/channels/:id(.:format) {:controller=>"channels", :action=>"show"} 
country_satellites GET /countries/:country_id/satellites(.:format)  {:controller=>"satellites", :action=>"index"} 
    country_satellite GET /countries/:country_id/satellites/:id(.:format) {:controller=>"satellites", :action=>"show"} 
country_testimonies GET /countries/:country_id/testimonies(.:format)  {:controller=>"testimonies", :action=>"index"} 
    country_testimony GET /countries/:country_id/testimonies/:id(.:format) {:controller=>"testimonies", :action=>"show"} 
country_statistics GET /countries/:country_id/statistics(.:format)  {:controller=>"statistics", :action=>"index"} 
    country_statistic GET /countries/:country_id/statistics/:id(.:format) {:controller=>"statistics", :action=>"show"} 
    country_videos GET /countries/:country_id/videos(.:format)   {:controller=>"videos", :action=>"index"} 
     country_video GET /countries/:country_id/videos/:id(.:format)  {:controller=>"videos", :action=>"show"} 
country_challenges GET /countries/:country_id/challenges(.:format)  {:controller=>"challenges", :action=>"index"} 
    country_challenge GET /countries/:country_id/challenges/:id(.:format) {:controller=>"challenges", :action=>"show"} 
      countries GET /countries(.:format)        {:controller=>"countries", :action=>"index"} 
        POST /countries(.:format)        {:controller=>"countries", :action=>"create"} 
     new_country GET /countries/new(.:format)       {:controller=>"countries", :action=>"new"} 
     edit_country GET /countries/:id/edit(.:format)     {:controller=>"countries", :action=>"edit"} 
      country GET /countries/:id(.:format)       {:controller=>"countries", :action=>"show"} 
        PUT /countries/:id(.:format)       {:controller=>"countries", :action=>"update"} 
        DELETE /countries/:id(.:format)       {:controller=>"countries", :action=>"destroy"} 
      channels GET /channels(.:format)        {:controller=>"channels", :action=>"index"} 
        POST /channels(.:format)        {:controller=>"channels", :action=>"create"} 
     new_channel GET /channels/new(.:format)       {:controller=>"channels", :action=>"new"} 
     edit_channel GET /channels/:id/edit(.:format)      {:controller=>"channels", :action=>"edit"} 
      channel GET /channels/:id(.:format)       {:controller=>"channels", :action=>"show"} 
        PUT /channels/:id(.:format)       {:controller=>"channels", :action=>"update"} 
        DELETE /channels/:id(.:format)       {:controller=>"channels", :action=>"destroy"} 
     satellites GET /satellites(.:format)       {:controller=>"satellites", :action=>"index"} 
        POST /satellites(.:format)       {:controller=>"satellites", :action=>"create"} 
     new_satellite GET /satellites/new(.:format)      {:controller=>"satellites", :action=>"new"} 
    edit_satellite GET /satellites/:id/edit(.:format)     {:controller=>"satellites", :action=>"edit"} 
      satellite GET /satellites/:id(.:format)      {:controller=>"satellites", :action=>"show"} 
        PUT /satellites/:id(.:format)      {:controller=>"satellites", :action=>"update"} 
        DELETE /satellites/:id(.:format)      {:controller=>"satellites", :action=>"destroy"} 
     testimonies GET /testimonies(.:format)       {:controller=>"testimonies", :action=>"index"} 
        POST /testimonies(.:format)       {:controller=>"testimonies", :action=>"create"} 
     new_testimony GET /testimonies/new(.:format)      {:controller=>"testimonies", :action=>"new"} 
    edit_testimony GET /testimonies/:id/edit(.:format)     {:controller=>"testimonies", :action=>"edit"} 
      testimony GET /testimonies/:id(.:format)      {:controller=>"testimonies", :action=>"show"} 
        PUT /testimonies/:id(.:format)      {:controller=>"testimonies", :action=>"update"} 
        DELETE /testimonies/:id(.:format)      {:controller=>"testimonies", :action=>"destroy"} 
     statistics GET /statistics(.:format)       {:controller=>"statistics", :action=>"index"} 
        POST /statistics(.:format)       {:controller=>"statistics", :action=>"create"} 
     new_statistic GET /statistics/new(.:format)      {:controller=>"statistics", :action=>"new"} 
    edit_statistic GET /statistics/:id/edit(.:format)     {:controller=>"statistics", :action=>"edit"} 
      statistic GET /statistics/:id(.:format)      {:controller=>"statistics", :action=>"show"} 
        PUT /statistics/:id(.:format)      {:controller=>"statistics", :action=>"update"} 
        DELETE /statistics/:id(.:format)      {:controller=>"statistics", :action=>"destroy"} 
      videos GET /videos(.:format)        {:controller=>"videos", :action=>"index"} 
        POST /videos(.:format)        {:controller=>"videos", :action=>"create"} 
      new_video GET /videos/new(.:format)       {:controller=>"videos", :action=>"new"} 
     edit_video GET /videos/:id/edit(.:format)      {:controller=>"videos", :action=>"edit"} 
       video GET /videos/:id(.:format)       {:controller=>"videos", :action=>"show"} 
        PUT /videos/:id(.:format)       {:controller=>"videos", :action=>"update"} 
        DELETE /videos/:id(.:format)       {:controller=>"videos", :action=>"destroy"} 
     challenges GET /challenges(.:format)       {:controller=>"challenges", :action=>"index"} 
        POST /challenges(.:format)       {:controller=>"challenges", :action=>"create"} 
     new_challenge GET /challenges/new(.:format)      {:controller=>"challenges", :action=>"new"} 
    edit_challenge GET /challenges/:id/edit(.:format)     {:controller=>"challenges", :action=>"edit"} 
      challenge GET /challenges/:id(.:format)      {:controller=>"challenges", :action=>"show"} 
        PUT /challenges/:id(.:format)      {:controller=>"challenges", :action=>"update"} 
        DELETE /challenges/:id(.:format)      {:controller=>"challenges", :action=>"destroy"} 
     all_channels  /all/channels(.:format)       {:controller=>"channels", :action=>"all"} 
    all_satellites  /all/satellites(.:format)      {:controller=>"satellites", :action=>"all"} 
    all_testimonies  /all/testimonies(.:format)      {:controller=>"testimonies", :action=>"all"} 
    all_statistics  /all/statistics(.:format)      {:controller=>"statistics", :action=>"all"} 
     all_videos  /all/videos(.:format)       {:controller=>"videos", :action=>"all"} 
    all_challenges  /all/challenges(.:format)      {:controller=>"challenges", :action=>"all"} 
       root  /(.:format)          {:controller=>"countries", :action=>"map"} 
       home  /home(.:format)         {:controller=>"countries", :action=>"map"} 
+1

你可以發佈您的視圖代碼/ html.erb/HAML?我想你是在混合使用足智多謀的路線或http方法,你使用普通的'form_for'嗎? –

+0

我不確定你爲什麼要在表單提交中獲得301,你能在表單上發佈實際POST的日誌而不是編輯/顯示的GET嗎?另外,你能否發佈與上述表格相關的'routes.rb'部分?它可能是控制器上的'before_filter'嗎? –

+0

該日誌發佈時發生了什麼。這就像它一起跳過POST請求。在開發中,它工作得很好。這很奇怪。 – Marc

回答

0

一件事,我以前碰到了,而與非數字的ID,分別爲默認制約resources路線。重寫這個約束解決了這個問題,但是這在開發模式中也應該是一個問題。反正,你可以嘗試

resources :countries, :constraints => { :id => /.*/ } 

再加上你的嵌套路線

+0

謝謝。除了輸入應用程序中沒有任何表單正在傳遞參數。它一起跳過POST請求。即使是登錄/註冊表單。無論如何,一切都很好。而gem'friendly_id'已經爲我處理了這個問題。 – Marc

+0

好的,最後的想法:你能展示你的中間件堆棧,用於開發和生產嗎? '耙中間件RAILS_ENV =開發'和'耙中間件RAILS_ENV =生產' –

+0

這裏是每個中間件堆棧:http://pastie.org/2602434 – Marc