MySQL2:查询期间与MySQL服务器的连接丢失
当我尝试使用union时,我收到以下错误:
ActionView::Template::Error (Mysql2::Error: Lost connection to MySQL server during query: SELECT `apps`.* FROM `apps` WHERE `verve_apps`.`status` IN (1, 2) AND (apps.id IN (SELECT apps.id FROM `apps` WHERE `apps`.`status` IN (1, 2) AND (app_name LIKE '%b%') UNION SELECT apps.id FROM `verve_apps` INNER JOIN taggings ON taggings.taggable_id = apps.id INNER JOIN tags ON tags.id = taggings.tag_id AND taggings.taggable_type = 'App' WHERE `apps`.`status` IN (1, 2) AND (tags.name = 'b') ORDER BY id ASC)) ORDER BY app_name asc LIMIT 10 OFFSET 0)
app.rb
class App "INNER JOIN taggings ON taggings.taggable_id = user.id\ INNER JOIN tags ON tags.id = taggings.tag_id AND taggings.taggable_type = 'App'", :conditions => ["tags.name = ?", tag], :order => 'id ASC' } } def self.search(search) if search union_scope(where('name LIKE ?', "%#{search}%") ,tagged_with(search)) else scoped end end end
user_controller.rb
class UserController per_page, :page => params[:page]) end
database.yml的
pipe_local_development: &pipe_local_development adapter: mysql2 encoding: utf8 reconnect: true database: app_development pool: 5 username: root password:
我能够从控制台运行此方法没有问题。