我有這樣的STI實現: class Instruction < ActiveRecord::Base
def get_view
return "I'm a pseudo abstract base method!"
end
end
class SCreateWebPage < Instruction
def get_view
return "
我有兩個模型共享一些相同的屬性,所以我想設置一個表繼承結構。之後做一些研究,我發現我可以用模塊通過執行來實現相同的,而不是執行以下操作: module CommonFields
def self.included base
base.class_eval do
include DataMapper::Resource
property :type, b
我在我的Rails應用程序中使用STI: class Project < ActiveRecord::Base
end
class Video < Project
end
我有以下途徑: resources :projects
resources :videos, :controller => "projects", :type => "video"
當我耙我路線我看到,我應該能
這讓我瘋狂!我有兩個型號Lion和Cheetah。兩者都從Wildcat繼承。 class Wildcat < ActiveRecord::Base; end
class Lion < Wildcat; end
class Cheetah < Wildcat; end
STI在這裏使用。 他們都通過控制器WildcatsController處理。在那裏,我有一個before_filer以獲
我有一類,那就是一些其他類的基礎,專業的行爲: class Task < ActiveRecord::Base
attr_accessible :type, :name, :command
validates_presence_of :type, :name, :command
# some methods I would like to test
end
我想在Rails 4中實現一些簡單的STI,但還有一些我還無法實現的東西。 我有以下類別: class Person < ActiveRecord::Base
end
class NaturalPerson < Person
end
class LegalPerson < Person
end
class Employee < NaturalPerson
end
class