2010-11-17 39 views
1

我是新來的Rails,但我需要在我的應用程序運行Ruby 1.9.2和Rails 3使用複合主鍵。我無法獲得組合鍵正常工作在我的Ruby on Rails應用程序中。我跟着the compositekeys site的方向,但我仍然得到同樣的錯誤: 沒有這樣的文件來加載 - composite_primary_keysRuby錯誤沒有這樣的文件加載 - composite_primary_keys

1 - sudo的創業板安裝composite_primary_keys
2 - 在末尾添加需要「composite_primary_keys」通過conf/environment.rb文件中
3 - 增加了set_primary_keys

我的寶石名單如下:

abstract (1.0.0) 
actionmailer (3.0.1) 
actionpack (3.0.1) 
activemodel (3.0.3, 3.0.1) 
activerecord (3.0.1) 
activeresource (3.0.1) 
activesupport (3.0.3, 3.0.1) 
arel (2.0.3, 1.0.1) 
builder (2.1.2) 
bundler (1.0.3) 
composite_primary_keys (2.3.5.1) 

我的領域類看起來是這樣的:

class Radioreport < ActiveRecord::Base 
    set_primary_keys :service_id, :date_id 
    belongs_to :report_date, :foreign_key => "date_id" 
    belongs_to :service, :foreign_key => "service_id" 
    ... 

而且我的環境文件看起來像這樣:

rake aborted! 
no such file to load -- composite_primary_keys 

單元測試是:

# Load the rails application 
require File.expand_path('../application', __FILE__) 
# Initialize the rails application 
Upreports::Application.initialize! 
require 'composite_primary_keys' 

的錯誤,我得到的是,當我跑我的「耙測試」以下:

require 'test_helper' 
require 'rubygems' 
require 'composite_primary_keys' 

class RadioreportTest < ActiveSupport::TestCase 
    fixtures :radioreports, :services, :genres, :groups, :locations, :report_dates 
    def setup 
    @radioReport = Radioreport.new 
    end 

    def test_should_put_all_radios_and_totals_in_a_hash 
    transactions = Radioreport.find(:all) 
    reportTransactions = @radioReport.getRadioTotalsByDayMap(transactions) 
    assert_not_nil(reportTransactions) 
    assert_equal(2, reportTransactions.size) 
    previousKey = nil 
    previousValue = nil 
    reportTransactions.each{|key, value| 
     if(previousKey == nil || previousValue == nil) 
     previousKey = key 
     previousValue = value 
     else 
     assert_not_nil(key) 
     assert_not_equal(previousKey, key) 
     assert_not_nil(value) 
     assert_not_equal(previousValue, value) 
     end 
    } 
    end 

我查了下thread,但這個不適用。我已經檢查過我的耙子,寶石等。
謝謝你們! ;)

回答

0

根據discussion in Github,CPK還不支持Rails 3.但是,似乎有人在各種各樣的分支中工作以使其工作。

相關問題