Tag: 干燥的

使用带有rails 3和dry_crud的Mongoid时替换column_names

我一直在Rails 3和Mongoid上飙升,并且在Grails的自动脚手架的愉快记忆中,当我发现时,我开始寻找ruby的DRY视图: http : //github.com/codez/dry_crud 我创建了一个简单的类 class Capture include Mongoid::Document field :species, :type => String field :captured_by, :type => String field :weight, :type => Integer field :length, :type => Integer def label “#{name} #{title}” end def self.column_names [‘species’, ‘captured_by’, ‘weight’, ‘length’] end end 但是由于dry_crud依赖于self.column_names并且上面的类不inheritance自ActiveRecord :: Base,我必须为column_names创建我自己的实现,如上所述。 我想知道是否可以创建一个默认实现,返回上面的所有字段,而不是硬编码列表?