ruby - (ActiveRecord::ConnectionNotEstablished)
PHP中文网
PHP中文网 2017-04-24 09:14:00
0
1
665
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)

不知为什么。

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
迷茫

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template