I have 2 tables news and news_type. Also I have 3 base types for news: politic, technology and sport. How I can filter this data by subdomain?
For example:
If I go to example.com I get all news in my home page
If I go to sport.example.com I get all news with type sport
And so on.
In your routes.rb file, you can provide constraints on the path. For example:
# routes.rb
...
get "/" => "sports#index", constraints: { domain: "sport.example.com" }
get "/" => "tech#index", constraints: { domain: "tech.example.com" }
root :to => 'static#index'
This would route
sport.example.com to the index action within SportsControllertech.example.com to the index action within TechsControllerexample.com to the index action within StaticControllerIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With