0

I get the error No route matches {:action=>"index", :controller=>"search"}

When using

link_to "Next Page", {:controller => 'search', :action => 'index'}

My routes.rb contains 
resources :search, only: [:index]

The action works fine when I use

link_to "Next Page", '/search'

Rake routes result

                          Prefix Verb  URI Pattern                                         Controller#Action
               errors_cookie GET   /errors/cookie(.:format)                            errors#cookie
                             GET   /categories(/:level1)(/:level2)(/:level3)(.:format) search#categories
                             GET   /category/filter/:type(.:format)                    search#category_filter_sort
                       brand GET   /brand(.:format)                                    search#brand
                             GET   /brand/filter/:type(.:format)                       search#brand_filter_sort
                search_index GET   /search(.:format)                                   search#index
              search_suggest GET   /search/suggest(.:format)                           search#suggest
                 search_list GET   /search/list(.:format)                              search#list
                             GET   /search/filter/:type(.:format)                      search#filter_sort
                             GET   /sd/:slug(.:format)                                 search#show
                             GET   /sd/compare/:id(.:format)                           search#compare
           delete_favourites POST  /favourites/delete(.:format)                        favourites#delete
           usuals_favourites GET   /favourites/usuals(.:format)                        favourites#usuals
           orders_favourites GET   /favourites/orders(.:format)                        favourites#orders
                  favourites GET   /favourites(.:format)                               favourites#index
                             POST  /favourites(.:format)                               favourites#create
Routes for Spree::Core::Engine:
                spree_user_omniauth_authorize GET|POST /users/auth/:provider(.:format)                                             spree/omniauth_callbacks#passthru {:provider=>/facebook|twitter|github|google_oauth2|amazon/}
                 spree_user_omniauth_callback GET|POST /users/auth/:action/callback(.:format)                                      spree/omniauth_callbacks#:action    
Routes for Ahoy::Engine:
visits POST /visits(.:format) ahoy/visits#create
events POST /events(.:format) ahoy/events#create
vinoy
  • 1
  • 3
  • If you run `rake routes`, it will show you all the routes defined in your app, could you try running that, and add the output to your question above, as that might help us debug your issue? – Alexander Kuzmin Dec 31 '15 at 05:13
  • I tried link_to for debugging after kaminari `link_to_next_page` failed with same error. Kaminari `paginate @object` works fine. – vinoy Dec 31 '15 at 05:32
  • Added shortened rake routes. Can't post the entire thing due to size constraint. – vinoy Jan 02 '16 at 03:52

1 Answers1

0

Its a spree app and the controller was inherited from Spree::BaseController. url_for only sees routes within the spree engine and not globals

Fixed the issue by adding main_app to url_for main_app.url_for(...)

Used this monkey patch for kaminari

Thanks for your time Alexander.

vinoy
  • 1
  • 3