Ruby Sequel::查找或创建时RecordNotFound异常
如果没有记录,Ruby Sequel::查找或创建时RecordNotFound异常,ruby,sequel,Ruby,Sequel,如果没有记录,find\u或\u create将返回nil,并传递一个块来创建一个记录 Sequel::RecordNotFound: Sequel::RecordNotFound from /RubyProjects/platform/lib/sequel/plugins/railsify.rb:48:in `find' from /RubyProjects/platform/lib/sequel/plugins/railsify.rb:69:in `find' fro
find\u或\u create
将返回nil,并传递一个块来创建一个记录
Sequel::RecordNotFound: Sequel::RecordNotFound
from /RubyProjects/platform/lib/sequel/plugins/railsify.rb:48:in `find'
from /RubyProjects/platform/lib/sequel/plugins/railsify.rb:69:in `find'
from /.rvm/gems/jruby-1.6.8/gems/sequel-3.43.0/lib/sequel/model/base.rb:331:in `find_or_create'
使用:
m = SAM::My_Model.find_or_create(:name => "foo") do |ds|
ds.organization = "Bar"
ds.name = "foo"
ds.remote_id = SAM::My_model::SOURCE_ID
end