Adjust namespace and scope for routes

This commit is contained in:
François Turbelin
2020-04-24 12:12:00 +02:00
parent b152e532d2
commit 80bbd5d513
3 changed files with 12 additions and 5 deletions

View File

@@ -1,10 +1,13 @@
# frozen_string_literal: true
# Controller used to provide the API products for the DFC application
module Api
module DfcProvider
class ProductsController < Api::BaseController
module DfcProvider
module Api
class ProductsController < ::Api::BaseController
skip_before_filter :authenticate_user
before_filter :set_enterprise
before_filter :authenticate_user
skip_authorization_check
def index
products = @enterprise.
@@ -20,6 +23,10 @@ module Api
private
def authenticate_user
@current_api_user = @enterprise.owner
end
def set_enterprise
@enterprise = ::Enterprise.find(params[:enterprise_id])
end

View File

@@ -2,7 +2,7 @@
DfcProvider::Engine.routes.draw do
namespace :api do
namespace :dfc_provider do
scope :dfc_provider, as: :dfc_provider, path: '/dfc_provider' do
resources :enterprises, only: :none do
resources :products, only: %i[index]
end

View File

@@ -13,6 +13,6 @@ Gem::Specification.new do |s|
s.email = ['admin@openfoodfrance.org']
s.summary = 'Provides an API stack implementing DFC semantic specifications'
s.files = Dir["{app,config,db,lib}/**/*"] + ['MIT-LICENSE', 'Rakefile', 'README.rdoc']
s.files = Dir["{app,config,db,lib}/**/*"] + ['README.rdoc']
s.test_files = Dir['test/**/*']
end