奇妙なルーティング エラーがあります。開発モードでは、すべてが順調で、世界は幸せな場所にあります。ただし、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
Gem のコントローラーをオーバーライドするカスタムの Devise コントローラーを作成したことを言及しておく必要があります。編集ページ (このエラーが発生する場所) には、そのページにフォームがあります。
ルートコマンドを上下に移動して、herokuを再起動しようとしました
どんな助けでも大歓迎です!!!