我有一个奇怪的路由错误。在发展模式上,一切都很好,世界处于一个快乐的地方。一旦我在Heroku上开发了开发,我就会得到一些奇怪的路由错误,这些错误在Dev中没有发生。我会选择最简单/最简单的解释一个在这里显示:
我的搜索字段部分在我的“登录”会话状态中无处不在。我可以导航到其他页面确定,使用搜索 - 没问题。当我尝试解析我的“编辑用户”页面时,事情就会中断。以下是让我相信问题出在我的搜索字段(heroku日志):
2012-06-06T03:12:39+00:00 app[web.1]: Started GET "/profile/edit" for 216.231.38.147 at 2012-06-06 03:12:39 +0000
2012-06-06T03:12:39+00:00 app[web.1]: Processing by Users::RegistrationsController#edit as HTML
2012-06-06T03:12:39+00:00 app[web.1]: Rendered users/registrations/edit.html.erb within layouts/application (6.7ms)
2012-06-06T03:12:39+00:00 app[web.1]: Rendered shared/navbar/_signed_in_menu.html.erb (7.0ms)
2012-06-06T03:12:39+00:00 app[web.1]: Rendered shared/navbar/_search_form.html.erb (59.1ms)
2012-06-06T03:12:39+00:00 app[web.1]: Rendered layouts/_header.html.erb (67.7ms)
2012-06-06T03:12:39+00:00 app[web.1]: Completed 500 Internal Server Error in 84ms
2012-06-06T03:12:39+00:00 app[web.1]:
**2012-06-06T03:12:39+00:00 app[web.1]: ActionController::RoutingError (No route matches {:controller=>"users/search", :action=>"search", :method=>"get", :class=>"navbar-search pull-right"}):**
2012-06-06T03:12:39+00:00 app[web.1]: app/views/shared/navbar/_search_form.html.erb:2:in `_app_views_shared_navbar__search_form_html_erb__1180266451204086_22567500'
2012-06-06T03:12:39+00:00 app[web.1]: app/views/layouts/_header.html.erb:8:in `_app_views_layouts__header_html_erb___173307722190207566_23782400'
2012-06-06T03:12:39+00:00 app[web.1]: app/views/layouts/application.html.erb:11:in `_app_views_layouts_application_html_erb__3823486473802009434_37056680'
2012-06-06T03:12:39+00:00 app[web.1]: app/controllers/users/registrations_controller.rb:15:in `edit'
问题是这一行(我认为):
ActionController::RoutingError (No route matches {:controller=>"users/search", :action=>"search", :method=>"get", :class=>"navbar-search pull-right"}):
有趣的是,错误中指定的控制器不是我对该部分的代码,这就是我的部分内容:
<div class = 'navbar-search pull-right'>
<%= form_tag controller: 'search', action: 'search', method: 'get', class: 'navbar-search pull-right' do %>
<div class="sign-in-fields-home">
<%= text_field_tag :search_query, nil, class: 'span4 search-query', placeholder: 'Search' %>
<%= submit_tag "Search", class: "submit navbar nav li a", type: 'hidden' %>
</div>
<% end %>
</div>
这是我的路线:
Mercado::Application.routes.draw do
match '/profile' => "users#show", as: :user_root
match "/profile" => "users#show" #To show singular resources
match '/search' => 'search#search' #to search resources
root :to => 'static_pages#home'
resources :users do
member do
get :followers, :following
end
resources :profilepictures, only: [ :index, :edit ]
end
resources :profilepictures, only: [ :create, :destroy, :update ]
resources :microposts, only: [ :create, :destroy ]
resources :relationships, only: [ :create, :destroy ]
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
devise_scope :user do
get '/signup' => 'users/registrations#new'
get '/signin' => 'devise/sessions#new'
delete '/signout' => 'devise/sessions#destroy'
get "/profile/edit" => 'users/registrations#edit' #to edit within the 'profile'
end
devise_for :users, :controllers => { :registrations => "users/registrations" }
这是我的Heroku Run Rake Routes的剪辑(相关部分):
user_root /profile(.:format) users#show
profile /profile(.:format) users#show
search /search(.:format) search#search
new_user_registration GET /users/sign_up(.:format) users/registrations#new
我应该提一下,我已经制作了自定义Devise控制器来覆盖Gem的控制器。编辑页面(发生此错误的位置)在该页面上有表单。
我尝试过上下移动路线命令并重新启动heroku
任何帮助将不胜感激!!!