I have these models:
Also I do have
So the question is:
1: how i can set relation between models ?
2: how i can set routs like this
Note : all of the countries don't have all sports for example Soccer Sport exist in all countries but volleyball exist in some countries
For 1. have a look at
many-to-many relationship. With Rails this can be done like follows:
has_many: sports, through: :country_sports
has_many :sports, through: :country_sports
The last model is the one that connects the Sport and Country model and for the bare minimum only need
For 2, you can nest the routes like follows:
resources :sports do
resources :country do
resources :leagues do
This is the gist of it, so feel free if you have specific issues with this.
Chris, it would be really great to see a video on how to set up nested routes properly. I have looked at every tutorial online, and nothing makes sense :D
Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.