module AhcHelper def render_ahc(template) if params[:format] == 'json' render json: @data else render text: Ahc.render(template, @data) end end end module AhcInheritedResourcesHelper include AhcHelper def respond_with(*resources, &block) controller = params[:controller].split('/').last action = params[:action] @data ||= {} @data['resources'] = collection render_ahc("#{controller}/#{action}") end end