2011-11-17 6 views
0

마이그레이션을 사용하여 SQL Server보기를 관리하려고합니다. rails_sql_views 확장 프로그램을 찾았지만 정확하게 필요한 것처럼 보였습니다. 그러나 마이그레이션을 실행할 때 오류가 발생했습니다. 알아낼 수 없습니다. 여기rails_sql_views 오류가 발생 했습니까?

rake aborted! 
An error has occurred, this and all later migrations canceled: 
uninitialized constant CreateFunds 

내 마이그레이션입니다 : 내가 레일 3.1.1를 사용하고 있습니다

class CreateFundView < ActiveRecord::Migration 
    def up 
    create_view :v_funds, "SELECT * from funds" 
    end 

    def down 
    drop_view :v_funds 
    end 
end 

가 여기에 오류입니다. 누구든지 나를 도울 수 있습니까?

+0

클래스 이름에 "s"를 누락 :

여기

https://github.com/mremolt/rails_sql_views.git

가 작동 마이그레이션입니다 : 여기에 노력하고 보석에 대한 링크는? 또는 클래스 이름이 마이그레이션 파일 이름과 일치하지 않습니까? –

+0

모든 것을 확인했습니다. 도움이된다면 여기에 스택 추적이 있습니다. https://gist.github.com/1371954 – SteveO7

+1

정말입니까? 마이그레이션 파일의 이름이'db/migrate/20111117101626_create_funds.rb'이며이 파일의 마이그레이션 클래스 이름은'CreateFundView'이지만 레일스는'CreateFunds' 클래스 이름을 찾을 것으로 예상합니다. 따라서 마이그레이션 파일의 이름을 바꾸거나 클래스 이름을 변경하여 일치 시키십시오. –

답변

0

레일즈 3.1.1과 호환되는 rails_sql_views gem을 업그레이드했습니다. (적어도 나는 그것이 그것을 고쳤다 고 생각한다!).

class CreateFundView < ActiveRecord::Migration 
    def up 
create_view :funds, 
      "SELECT  TOP (100) PERCENT 
       FUND.FUND_ID AS [fund_id], 
       FUND.DESCRIPTION AS [fund_description], 
       FUND_FUND_CATEGORY.LONGDESCRIPTION AS [fund_category], 
       FUND.NOTES AS [fund_notes] 
       FROM 
       RE7.dbo.FUND AS FUND LEFT OUTER JOIN 
       RE7.dbo.TABLEENTRIES AS FUND_FUND_CATEGORY ON FUND.FUND_CATEGORY = FUND_FUND_CATEGORY.TABLEENTRIESID 
       WHERE  (FUND.FUNDTYPE = 23702) 
       ORDER BY [fund_description]" 
    end 

    def down 
    drop_view :funds 
    end 
end 
관련 문제