Undefined `explain 'method for # <ActiveRecord :: ConnectionAdapters :: MysqlAdapter

I'm new to Ruby on Rails, but I followed some tutorials and know a little. I created some forests and inserted the data into the MySql database.

When navigating index.html.erb, I get an error in the header

Controller executes index

def index @beers = Beer.all respond_to do |format| format.html # index.html.erb format.json { render :json => @beers } end end 

And has it as a structure

 Beer: id, brewer_id, name, price, score, color, brew_type, create_at, updated_at 

RoR works for the other scaffolding I created, and data enumerations. I updated the structure in mysql for the Beer entity and probably did not reflect the changes in rails (dunno).

Do I need another stone to connect rails to mysql db? Any advice on what to check would be appreciated (:

+7
source share
1 answer

I assume that you are using Rails 3.2 and that your call to Beer.all takes too much time. From 3.2 release notes :

Queries that take more than half a second to run are automatically described in design mode. This threshold, of course, can be changed.

And if we look at the MySQL adapter for Rails , there is no explain method. However, the MySQL2 adapter understands explain .

First of all, you probably need less beer or some kind of pagination. Then you should try switching to the MySQL2 adapter; just install the new adapter by editing your Gemfile to use mysql2 , run bundle to set up new stuff, and then change your database.yml to look more like this:

 development: adapter: mysql2 
+24
source

All Articles