I'm doing an API in ruby on rails. I have 2 methods that returns resources in json. These 2 resources don't have any relation with each other. What I want to do is build a method to return these 2 resources in one request. What is the best way to do that without harming the restful principles? Should I maintain this way?
Edit
My files to explain myself better.
routes.rb
resources :cities, only: [:index]
resources :products, only: [:index]
cities_controller.rb
class CitiesController < ApplicationController
respond_to :json
def index
@cities = City.all
render :json => @cities
end
end
products_controller.rb
class ProductsController < ApplicationController
respond_to :json
def index
@products = Product.all
render :json => @products
end
end
Should I create a third controller and route to get this two resources together in one JSON? Is that the better way?