Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ActionView::Template::Error(Mysql2::Error::ConnectionError:错误或未知协议:选择_Mysql_Ruby On Rails_Mysql2_Actionview - Fatal编程技术网

ActionView::Template::Error(Mysql2::Error::ConnectionError:错误或未知协议:选择

ActionView::Template::Error(Mysql2::Error::ConnectionError:错误或未知协议:选择,mysql,ruby-on-rails,mysql2,actionview,Mysql,Ruby On Rails,Mysql2,Actionview,我在rails应用程序中遇到了这个奇怪的错误 Completed 500 Internal Server Error in 176742ms (ActiveRecord: 148.5ms) ActionView::Template::Error (Mysql2::Error::ConnectionError: Wrong or unknown protocol: SELECT `lines`.* FROM `lines` WHERE `lines`.`id` = 15 LIMIT 1):

我在rails应用程序中遇到了这个奇怪的错误

Completed 500 Internal Server Error in 176742ms (ActiveRecord: 148.5ms)



ActionView::Template::Error (Mysql2::Error::ConnectionError: Wrong or unknown protocol: SELECT  `lines`.* FROM `lines` WHERE `lines`.`id` = 15 LIMIT 1):
    22:               <% if defined?(Haml) && respond_to?(:block_is_haml?) && block_is_haml?(block) %>
    23:                 <% capture_haml(day, sorted_events.fetch(day, []), &block) %>
    24:               <% else %>
    25:                 <% block.call day, sorted_events.fetch(day, []) %>
    26:               <% end %>
    27:             <% end %>
    28:           <% end %>

app/views/presences/index.html.erb:47:in `block (2 levels) in _app_views_presences_index_html_erb__679688437_89682920'
app/views/presences/index.html.erb:7:in `each'
app/views/presences/index.html.erb:7:in `block in _app_views_presences_index_html_erb__679688437_89682920'
app/views/presences/index.html.erb:3:in `_app_views_presences_index_html_erb__679688437_89682920'
在176742ms内完成了500个内部服务器错误(ActiveRecord:148.5ms)
ActionView::Template::Error(Mysql2::Error::ConnectionError:错误或未知协议:从'lines'中选择'lines`.*,其中'lines`.'id`=15限制1):
22:               
23:                 
24:               
25:                 
26:               
27:             
28:           
app/views/presences/index.html.erb:47:in'block(2层)in_app_views_presences_index_html_erb_679688437_89682920'
app/views/presences/index.html.erb:7:in'each'
app/views/presences/index.html.erb:7:in`block in_app_views_presences_index_html_erb_679688437_89682920'
app/views/presences/index.html.erb:3:in`_app\u views\u presences\u index\u html\u erb\u 679688437\u 89682920'
app/views/presence/index.html.erb:47:

<th style="background: greenyellow"><%= Line.find(l).name + " bla: " + tmp.size.to_s %></th>


有人知道如何修复这个问题,或者知道为什么会出现mysql错误吗?在前面的代码中,我对数组执行了一些select和detect语句。mysql查询不多……而这个错误只发生在我的测试环境中(不同VM上的生产环境副本)。在我的开发环境中,一切都很好。

我用新配置在当前版本上重新安装MySQL服务器,解决了这个问题。不知何故,不需要更改代码…

看起来您没有“行”表。转到rails控制台并确保它。它在那里。我也可以在任何其他视图中访问它。上面显示的SQL查询也可以在我的SQL控制台中工作,可能在
行中。find(l)
缺少
l
,有趣的案例从未见过这种情况?我以前在视图行中访问
l
,但在另一个案例中使用了相同的代码,它可以工作。如果没有,它将在第
行app/views/presences/index.html.erb:17
中抛出一个错误。我重构了代码以解决一个n+1问题,此后它就失败了为了使用奇怪的mysql错误运行,我能够以不同的方式重构代码以避免问题。但是现在我的(rufus-)调度程序中出现了相同的问题。当应用程序启动第一次运行时,第二次运行会因大小而失败:SELECT COUNT()从
导出
其中
导出
日期='2020-02-11'配置/初始化器/调度程序。rb:21 Mysql2::错误::连接错误:错误或未知协议:选择计数()从
exports
WHERE
exports
date='2020-02-11'D:/RubyonRails/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.5.3-x64-mingw32/lib/mysql2/client.rb:131:“\u查询”中是否存在并发问题?