Rails 4, subdomain routing
问题 Trying to implement web service in rails through API sub-domain called "api". In my hosts file i added line: 127.0.0.1 api.localhost In my routes.rb i set sub-domain, where i only need index action and few manually added restful routes, through following: namespace :api, path: '', :constraints => {:subdomain => "api"} do resources :posts, only: :index do collection do get 'popular_by_day' get 'popular_by_week' end end end Also generated coresponding controller with: rails g controller api