Not sure why this is happening. I'm getting <subject> as an error. I've
tried using both directive and non-directive for @id in the initialize
method, with same error. Seems the object is the same column profile. Any
clue why this is happening?
DL.create_table? :mobibase do
primary_key :id
DateTime :cdate
String :label, size: 200
String :note, size: 350
String :status, size: 20, default: 'new'
end
class Mobibase < Sequel::Model(DL[:mobibase])
def initialize(cdate, label, note)
# @id = nil
@cdate = cdate
@label = label
@note = note
@status = 'new'
puts "A new instantiation"
end
def inspect
self.instance_variables.each do |i|
puts "#{ i }: #{ instance_variable_get(i) }"
end
end
end
puts "db columns:"
puts DL[:mobibase].columns
item = Mobibase.new(cdate = 'Aug 27, 2021', label = 'My label', note =
'Bravo, well done')
item.inspect
puts
item.save
Results in...
db columns:
id
cdate
label
note
status
A new instantiation
@cdate: Aug 27, 2021
@label: My label
@note: Bravo, well done
@status: new
Traceback (most recent call last):
18: from /users/rich/app.rb:301:in `<main>'
17: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1488:in
`save'
16: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1930:in
`checked_save_failure'
15: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1488:in
`block in save'
14: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1942:in
`checked_transaction'
13: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/database/transactions.rb:195:in
`transaction'
12: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/database/connecting.rb:269:in
`synchronize'
11: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/connection_pool/threaded.rb:92:in
`hold'
10: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/database/transactions.rb:233:in
`block in transaction'
9: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/database/transactions.rb:258:in
`_transaction'
8: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1942:in
`block in checked_transaction'
7: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1488:in
`block (2 levels) in save'
6: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1776:in
`_save'
5: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1038:in
`around_save'
4: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1794:in
`block in _save'
3: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1038:in
`around_update'
2: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1802:in
`block (2 levels) in _save'
1: from
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1846:in
`_save_update_all_columns_hash'
/Users/rich/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sequel-5.46.0/lib/sequel/model/base.rb:1846:in
`[]': odd number of arguments for Hash (ArgumentError)
Cheers
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/1056e9c8-e4eb-4dfc-a0fe-01a185d93ee1n%40googlegroups.com.