find_or_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