Ruby 如何在Sequel中为表视图创建方法?

Ruby 如何在Sequel中为表视图创建方法?,ruby,sequel,Ruby,Sequel,我在Sequel中创建了一个表视图,并将其放入一个文件db\u views.rb: require 'db_manip' Db_manip::DB.create_view(:bn_view,'SELECT ...') 为了遵循“胖模型瘦控制器”的实践,我想为:bn_view创建一些方法。您是否尝试过: class BnView < Sequel::Model(:bn_view) def foo # implement your method here end en

我在Sequel中创建了一个表视图,并将其放入一个文件
db\u views.rb

require 'db_manip'    
Db_manip::DB.create_view(:bn_view,'SELECT ...')
为了遵循“胖模型瘦控制器”的实践,我想为
:bn_view

创建一些方法。您是否尝试过:

class BnView < Sequel::Model(:bn_view)
  def foo
    # implement your method here
  end
end
classbnview
假设您有一个模型,我猜您会希望使用dataset_模块向模型的数据集中添加方法。对于普通数据集,只需使用包含这些方法的模块对其进行扩展。但是你需要更具体地说明你想要做什么。谢谢你的回答我需要的实际上是一个类方法。所以我使用def self.foo