Ruby(ITのバックグラウンドなし)で遊び始め、前の質問/回答(リンク)に基づいてプロジェクトを再開しました。私は今、次の状況に陥っています。
次の列を持つcurrencymasterテーブルを作成しました。これにより、ID列はRubyによって作成されます。id:integerdescription:stringisocode:string
次の列を持つcurrencyratesテーブルを作成しまし た。これにより、ID列がRubyによって作成されます。id:integerdominant:integerconverted:integerrate:decimal
このサイトのヘルプに基づいて、次のモデルを作成しました。models/currencymaster.rbは次のようになります。
class Currencymaster < ActiveRecord::Base
has_many :currency_rates_dominant, :validate => true, :class_name => 'Currencyrate'
has_many :currency_rates_converted, :validate => true, :class_name => 'Currencyrate'
end
models/currencyrate.rbは次のようになります。
class Currencyrate < ActiveRecord::Base
belongs_to :currency_master_doms, :class_name => 'Currencymaster'
belongs_to :currency_master_convs, :class_name => 'Currencymaster'
end
両方のコントローラーでまだ何も変更していません。
views \ currencyrates \ index.html.erbは、Rubyを介して自動的に生成され、レコードの値を整数として表示しています。目標は、両方のテーブルから値を表示することですcurrencymaster.iso。Currencymastercurrencyrate.dominantcurrencyrate.converted
どうもありがとう!!