jeudi 28 janvier 2016

Rails Take all actions in the controllers in area

In my rails application I add an "api" area with controllers

In the route.rb file I add the area

namespace :api do
   #get "dashboard/sales_rate"
  end

The controllers Class:

class Api::DashboardController < Api::ApplicationController
 before_filter :authenticate_user!

  def user_service
    render :json => {"user_id" => current_user.id}
  end

The Path is: app/controllers/api/dashboard_controller

My question is if I can that the route take all action

for example /api/dashboard/user_service and I will not add for each route row on the route.rb page

/api/{controller_under_api_namespace}/{action}

Aucun commentaire:

Enregistrer un commentaire