0

My routes file contains:

  concern :generic_table do
    get 'search_suggestions' => 'search_suggestions'
  end

  get 'human_resources/' => 'human_resources#index'
  namespace :human_resources do
    get 'settings/' => 'settings#index'
    namespace :settings do
      resources :constants do
        concerns :generic_table
      end
    end
  end

And it produces:

/human_resources/settings/constants/:constant_id/search_suggestions(.:format) 

human_resources/settings/search_suggestions#search_suggestions

I am trying to remove the /:constant_id/ part and it point to the controller action:

human_resources/settings/constants/search_suggestions#search_suggestions

So in finality it would be

/human_resources/settings/constants/search_suggestions(.:format)

human_resources/settings/constants/search_suggestions#search_suggestions

How can I remove the /:constant_id/ part; and point it directly to my controllers action so my search bar my access the search suggestion for AJAX?

james
  • 515
  • 4
  • 14

1 Answers1

0

I think you just need to replace the resources block by a namespace one. It is the resources block that generates the parameter.

See also the member block if you need id instead of constant_id.

One extra point: This may not generate the route helpers you want. There are extra options to pass to namespace and related to tailor the helpers.

Eric Platon
  • 9,819
  • 6
  • 41
  • 48