0

I implemented this link:

View:

<li><%= link_to "Trainer-Sportler", :controller => "trainerones", :action => "trspmatch" %></li>

controller:

def trspmatch
   render :trspmatch
end

and one view trspmatch.html.erb

Rails says:

Unknown action

The action 'show' could not be found for TraineronesController

When i implemented def show end and create a show.html.erb. Rails opens the show.html.erb not the trspmatch.html.erb?

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
ubuseral
  • 427
  • 1
  • 3
  • 14
  • 2
    Show us your routes.rb file so we can help – boulder Feb 21 '13 at 21:17
  • the important part of my routes.rb: – ubuseral Feb 21 '13 at 21:50
  • resources :trainerones do get "trainerones/index" get "trainerones/trspmatch" get "trainerones/imports" end resources :sportlers do get "sportlers/index" end resources :administrators do get "administrators/index" end resources :people do get :check_valid, on: :member get :save_formular, on: :member get :make_paars, on: :member resources :orts resources :trainingseinheits resources :photos resources :plans resources :tagebuches end – ubuseral Feb 21 '13 at 21:51
  • match 'people/trspmatch/check_valid' => 'people#check_valid' match 'people/make_paars' => 'people#make_paars' match 'people/save_formular' => 'people#save_formular' match 'trainerones/trspmatch' => 'trainerones#trspmatch' match 'trainerones/new' => 'trainerones#new' match 'trainerones/imports' => 'trainerones#imports' – ubuseral Feb 21 '13 at 21:52
  • Perhaps better if you show that in your question instead. – 244an Feb 21 '13 at 22:08

1 Answers1

2

You probably want to define your trainerones resource like this:

resources :trainerones do
   collection do
     get 'trspmatch'
   end
end

that will expose a url /trainerones/trspmatch that maps to TraineronesController#trspmatch. It seems that a look at this link will help you understand routes better.

In any case, you will benefit a lot from running rake routes in your console, which will display all your routes and how they map to your controllers methods. Try before and after rewriting your trainerones resource as I explained above, and you'll see the difference. Good luck!

boulder
  • 3,256
  • 15
  • 21