From 57825439e68e62fc6844bee6c666ac7ad2f01bca Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 1 Jun 2018 16:10:05 +0100 Subject: Change the signature of Backends.find_by_type_and_id It now takes two arguments, and when used by the MiniEnvironmentsController, the split is performed there. This makes it easier to reuse elsewhere in the codebase. --- app/controllers/mini_environments_controller.rb | 2 +- app/models/backends.rb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/controllers/mini_environments_controller.rb b/app/controllers/mini_environments_controller.rb index 237e8c5..0cee75b 100644 --- a/app/controllers/mini_environments_controller.rb +++ b/app/controllers/mini_environments_controller.rb @@ -90,7 +90,7 @@ class MiniEnvironmentsController < ApplicationController .except(:backend) ) @mini_environment.backend = Backends.find_by_type_and_id( - parameters[:backend] + *parameters[:backend].split('=') ) @mini_environment.signon_users[0]['passphrase'] = SecureRandom.hex @mini_environment.save! diff --git a/app/models/backends.rb b/app/models/backends.rb index 0caf8fe..526ae76 100644 --- a/app/models/backends.rb +++ b/app/models/backends.rb @@ -40,9 +40,7 @@ module Backends classes.flat_map(&:all) end - def self.find_by_type_and_id(type_and_id) - type_name, id = type_and_id.split('=') - + def self.find_by_type_and_id(type_name, id) type = classes.find { |c| c.name == type_name } type.find(id.to_i) -- cgit v1.2.3