I’m having trouble nesting my routes. It would probably be easiest to show you the code. Here is my routes.rb file:
resources :leagues do
get 'delete', :on => :member
resources :league_relations do
get 'delete', :on => :member
end
end
Each League has_many :league_relations, and each LeagueRelation belongs_to :league. The delete route there is just a confirmation before the destroy action.
I am trying to use Rails’ path helpers, but they are not working for some reason. Specifically, I am trying to do this:
new_league_league_relation_path
But this raises the error:
No route matches {:action=>”new”, :controller=>”league_relations”}
Technically, the error is correct. There is no route matches ‘league_relations#new’, but shouldn’t the URL created by this helper be
/leagues/:id/league_relations/new
Thanks for your help, I really appreciate it.
Actually route is exactly as you expect it to be. You just forgot to add :league_id
This will work: