mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Dry current_enterprise emtod with enterprise_id_param_name
This commit is contained in:
@@ -32,13 +32,17 @@ module DfcProvider
|
||||
|
||||
def current_enterprise
|
||||
@current_enterprise ||=
|
||||
if params[:enterprise_id] == 'default'
|
||||
if params[enterprise_id_param_name] == 'default'
|
||||
current_user.enterprises.first!
|
||||
else
|
||||
current_user.enterprises.find(params[:enterprise_id])
|
||||
current_user.enterprises.find(params[enterprise_id_param_name])
|
||||
end
|
||||
end
|
||||
|
||||
def enterprise_id_param_name
|
||||
:enterprise_id
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= authorization_control.process
|
||||
end
|
||||
|
||||
@@ -10,13 +10,8 @@ module DfcProvider
|
||||
|
||||
private
|
||||
|
||||
def current_enterprise
|
||||
@current_enterprise ||=
|
||||
if params[:id] == 'default'
|
||||
current_user.enterprises.first!
|
||||
else
|
||||
current_user.enterprises.find(params[:id])
|
||||
end
|
||||
def enterprise_id_param_name
|
||||
:id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user