Sequel set_schema not found

Can someone volunteer to explain why the class below does not work?

... src/model/user.rb:18: undefined method `set_schema' for User:Class (NoMethodError) 

I looked at the Sequel-3.0 lib / folder, and the set_schema method set_schema defined in the ClassMethods module.

I am sure the solution is simple. I thought it should work "as is":

 require 'sequel' class User < Sequel::Model(:user) set_schema do set_primary_key :id String :name end end 
+4
source share
3 answers

Recommended Method ...

 LOGGER = Object.new() def LOGGER.method_missing( name, args ) puts "[#{name}] #{args}" end Sequel::Model.plugin(:schema) # I worked this out, but I can't find it documented DB = Sequel.sqlite('sql_test.db', :loggers => [LOGGER] ) unless DB.table_exists?( :user ) DB.create_table :user do set_primary_key :id String :name String :password String :eMail end #create_table end #table exists class User < Sequel::Model(:user) 
+4
source

The answer lies in calling the plugin to control the circuit. Viz.

 require 'sequel' require 'logger' LOGGER = Object.new() def LOGGER.method_missing( name, args ) puts "[#{name}] #{args}" end **Sequel::Model.plugin(:schema)** # I still didn't find this documented DB = Sequel.sqlite('sql_test.db', :loggers => [LOGGER] ) class User < Sequel::Model(:user) set_schema do set_primary_key :id String :name end end 
+3
source

Yep Sequel::Model.plugin(:schema) worked for me Sequel::Model.plugin(:schema) . I don’t see it in the documents, and I wonder why, since I have another working project that uses set_schema without fuss.

+1
source

All Articles