Rails 4 Routing conflict -


i rewritting rails app did 5 years ago using rails 1.something. when try browse localhost/companies/search_updates/ error... know routing error because when remove resources :companies router.rb thing works fine... how can fixed? , need manually add routes every action create?

error when try access localhost/companies/search_updates/

the action 'show' not found companiescontroller 

controler

class companiescontroller < applicationcontroller   def index     @companies = company.all   end   def search_updates     # execute code search updates     # redirect results   end end 

routes

resources :accounts resources :companies 'companies/search_updates' =>   'companies#search_updates' 

search_updates.html.erb

hello updates! 

the action 'show' not found companiescontroller

rails routes matched in order specified, if have resources :companies above 'companies/search_updates' show action's route resources line matched before line. fix this, move line above resources line matched first.

resources :accounts 'companies/search_updates' =>   'companies#search_updates' resources :companies 

and

resource routing allows declare of common routes given resourceful controller. instead of declaring separate routes index, show, new, edit, create, update , destroy actions, resourceful route declares them in single line of code.

if have index method (default curd rails) on controller, can specific routes it.

resources :accounts 'companies/search_updates' =>   'companies#search_updates' resources :companies, :only => [index] 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -