mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Work around possible regression in rails
`pluck` used to always trigger a database query. With Rails 5.0.1 it uses data from already loaded associations, this also includes new records for which we can not generate agent_paths
This commit is contained in:
parent
0285a1a993
commit
070946e879
1 changed files with 1 additions and 1 deletions
|
@ -52,7 +52,7 @@
|
|||
window.agentPaths = {};
|
||||
window.agentNames = [];
|
||||
<% if current_user.present? -%>
|
||||
var myAgents = <%= Utils.jsonify(current_user.agents.pluck(:name, :id).inject({}) {|m, a| m[a.first] = agent_path(a.last); m }) %>;
|
||||
var myAgents = <%= Utils.jsonify(current_user.agents.pluck(:name, :id).inject({}) {|m, a| next if a.last.nil?; m[a.first] = agent_path(a.last); m }) %>;
|
||||
var myScenarios = <%= Utils.jsonify(current_user.scenarios.pluck(:name, :id).inject({}) {|m, s| m[s.first + " Scenario"] = scenario_path(s.last); m }) %>;
|
||||
$.extend(window.agentPaths, myAgents);
|
||||
$.extend(window.agentPaths, myScenarios);
|
||||
|
|
Loading…
Add table
Reference in a new issue