require 'active_record'
class Movie < ActiveRecord::Base
end
movie = Movie.new(1)
movie.title = "Doctor Strangelove"
movie.director = "Stanley Kubrick"
以上代码运行报错:
in `retrieve_connection': No connection pool for Movie (ActiveRecord::ConnectionNotEstablished)
不知为什么。
迷茫2017-04-24 09:16:00
Look at your code. You should be reading ruby metaprogramming second edition
But you didn’t read it carefully. The clear explanation of this code in the book is as follows: This code creates a record in the movies table, title
and director. You should not have created a database or have no connection to the database this time. Recording failed
Have a good look at activerecord