Using Rails v 3.0.11, Ruby v 1.9.3
I have a page having link "Reports" on it, clicking on which invokes ReportsController#index
class ReportsController < ApplicationController
def index
# Renders index.html.haml
end
end
Now I have an already existing JSON API (ReportsDataController shown below) returning JSON response which I need to reuse.
A Controller returning JSON response (my JSON API)
class ReportsDataController < ApplicationController
respond_to :json
def users_events_activity
user_activity_data_obj = find_user_events_activity_per_day
respond_with user_activity_data_obj
end
def users_comments_activity
user_comments_data_obj = find_user_comments_activity_per_day
respond_with user_comments_data_obj
end
end
On my app/views/reports/index.html.haml I need to simultaneously render the data returned by actions ReportsDataController#users_events_activity and ReportsDataController#users_comments_activity.
Is there a Rails standard way by which the above mentioned requirement can be achieved? If not can anybody please suggest me some approaches to achieve the same?
Thanks,
Jignesh