sti

    0熱度

    3回答

    我使用單表繼承在我的應用程序和運行合適的班級爲構建繼承用戶從一個祖先的問題。舉例來說,有以下設置: class School < ActiveRecord::Base has_many :users end class User < ActiveRecord::Base attr_accessible :type #etc... belongs_to

    1熱度

    1回答

    我有以下設置,模型客戶端是模型聯繫人的子類。 STI表是聯繫人。 然後在測試代碼中調用 it "should have the right clients in the right order" do @producer.clients.should == [a_client, b_client] end 用SQL語句錯誤地解決不存在客戶表中的ORDER BY子句時,我得到一個錯誤

    0熱度

    1回答

    我有一個STI模型,我希望可以使用ElasticSearch和Tire進行搜索。我遇到的問題是,當Tyre創建映射時,它似乎忽略了第二個模型的自定義分析器。以下是我的模型的一個例子。 class Account < ActiveRecord::Base attr_accessible :name, :type include Tire::Model::Search

    0熱度

    1回答

    我正在使用STI創建一個具有用戶父項和兩個子項僱主和求職者的應用程序。這些關係已經建立和測試。 我想使用STI將僱主用戶和求職用戶存儲到僅使用1個用戶控制器的Postgres中。 我使用form_tag輸入細節。我已創建 <%= hidden_field_tag :user_type, :jobseeker %> <%= hidden_field_tag :user_type, :employe

    0熱度

    3回答

    想不通爲什麼會發生: class Foo < ActiveRecord::Base belongs_to :belongable, :polymorphic => true def after_save if belongable.kind_of?(User) send(:some_method) end end end cla

    0熱度

    1回答

    我使用STI(正確的,我保證!)爲對象的一個​​關係: class Walrus < ActiveRecord::Base has_one :bubbles end class Bubbles < ActiveRecord::Base belongs_to :walrus before_save :set_origin private d

    1熱度

    1回答

    我第一次使用STI創建了一個應用程序,並且我偶然發現了一個令人困惑的障礙。 考慮以下兩種型號,並繼承: User.rb class User < ActiveRecord::Base attr_accessible :email, :first_name, :last_name, #more follows Waiter.rb class Waiter < User 我在/服務員/

    4熱度

    1回答

    我有一個STI關係,對話由消息和圖像組成。 現在,當我去使它們使用: <%= render conversation %> 它可以完美運行。它找到給定對象的給定模板並呈現它。 現在對於我的移動網站,我想用同樣的事情只是現在它應該找到說: /mobile/message/_message.html.erb ,而不是 /message/_message.html.erb 所以在我的控制,我

    1熱度

    2回答

    在我的Rails應用程序我有模特這樣 class Account < ActiveRecord::Base class Account::Bonus < Account class Account::Virtual < Account ...more 而且這樣 class DiscountSystem < ActiveRecord::Base class DiscountSystem:

    2熱度

    2回答

    我有一個模型和表格,我認爲它非常適合STI。我的表叫做Finances,有兩種類型:收入和支出。除了type還有其他三列:description,amount和date。 我在Rails中使用STI越來越緊張,因爲它需要一些黑客攻擊。我對Rails破解代碼太陌生了。即使它有效,我也不明白。這似乎很危險。 我的問題是,如果我不使用STI,如何設置我的模型,控制器和視圖?任何將我的模型中的項目分組的最