sti

    3熱度

    2回答

    我需要幫助實現或將其分解爲單表繼承(STI)。我已經閱讀過有關這方面的內容,但如果我以正確的方式開展工作,我還不太確定。如果你們有建議來實施它。或者,即使它與我現在有很大不同,請諮詢。 所以,通常我有以下類(所有模型)。 class Article < ActiveRecord::Base has_many :attachments has_many :medias

    2熱度

    1回答

    我有這樣的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 "

    1熱度

    1回答

    我有兩個模型共享一些相同的屬性,所以我想設置一個表繼承結構。之後做一些研究,我發現我可以用模塊通過執行來實現相同的,而不是執行以下操作: module CommonFields def self.included base base.class_eval do include DataMapper::Resource property :type, b

    0熱度

    3回答

    我在我的Rails應用程序中使用STI: class Project < ActiveRecord::Base end class Video < Project end 我有以下途徑: resources :projects resources :videos, :controller => "projects", :type => "video" 當我耙我路線我看到,我應該能

    7熱度

    2回答

    這讓我瘋狂!我有兩個型號Lion和Cheetah。兩者都從Wildcat繼承。 class Wildcat < ActiveRecord::Base; end class Lion < Wildcat; end class Cheetah < Wildcat; end STI在這裏使用。 他們都通過控制器WildcatsController處理。在那裏,我有一個before_filer以獲

    3熱度

    3回答

    感謝您的閱讀。 我正在使用Devise和Rails 4.我想添加多個用戶模型(admin,usertype1,usertype2),以便它們從主用戶模型繼承。我已經搜索了很多帖子,並得出結論,我可以使用CanCan,我不想,或者我可以使用Single Table Inheritance。 我看到它的方式是將類型字符串列添加到我用Devise創建的主用戶模型中。我還需要將父級的每個子級擴展爲: cl

    0熱度

    1回答

    我設立一個active_admin應用程序,並具有下列STI結構 class Organization < ActiveRecord::Base attr_accessible :name, :type end class Contractor < Organization def self.model_name return Organization.mode

    0熱度

    1回答

    我有一個STI類層次結構如下所示: Producer, Partner, Freelancer < Statusowner < Contact 當我打電話例如Partner.all我看到鐵軌生產這樣的: SELECT "contacts".* FROM "contacts" WHERE "contacts"."type" IN ('Partner', 'Producer', 'Partner'

    22熱度

    1回答

    我有一類,那就是一些其他類的基礎,專業的行爲: class Task < ActiveRecord::Base attr_accessible :type, :name, :command validates_presence_of :type, :name, :command # some methods I would like to test end

    2熱度

    2回答

    我想在Rails 4中實現一些簡單的STI,但還有一些我還無法實現的東西。 我有以下類別: class Person < ActiveRecord::Base end class NaturalPerson < Person end class LegalPerson < Person end class Employee < NaturalPerson end class