2013-07-04 11 views
0

因此,我生成了我的紅寶石軌道項目的腳手架,只是爲了發現我已經添加了一列,我不再需要。刪除表列中的耙測試錯誤

我生成了一個遷移並刪除了額外的列。

然後我刪除了在代碼中調用的所有列。

但是當我運行一個「耙測試」我得到幾個錯誤,他們似乎在這個不存在的列被人指指點點,我修改了controller_test.rb

@foo = foos(:one) 
    @update = { 
    title:  'Lorem Ipsum', 
    description: 'Wibbles are fun!', 
    image_url: 'lorem.jpg', 
    start_date: '12/12/13', 
    end_date: '13/12/13' 
    } 

我還修改了應創建測試和應該更新測試

test "should create foo" do 
assert_difference('Foo.count') do 
    post :create, foo: @update 
end 

test "should update foo" do 
put :update, id: @foo, foo: @update 
assert_redirected_to foo_path(assigns(:foo)) 
end 

任何幫助將是REA lly讚賞,如果需要更多的信息,我可以提供更多的

回答

1

我發現這個問題持續存在的幾個小時後。

而列從表中刪除,仍有引用的給它的項目,在我的情況下,它在這裏測試/夾具/ foo.yaml

找出無處不在的具體線路(如果您的IDE沒有搜索功能)到您的工作你自己的Git的bash提到去和運行

$ grep -r "search term" * 

它挑選出迪爾搜索項在於,在此之後它只是剛剛刪除所有引用一個簡單的例子因爲它

n注意這個命令給你所尋找的所有線條分佈在底部。

0

你是新來的鐵軌嗎?如果是的話,你能告訴我什麼指導你following.And你如何產生的支架

腳手架創建所有這些文件

invoke active_record 
    create db/migrate/20130704111616_create_products.rb 
    create app/models/product.rb 
    invoke test_unit 
    create  test/models/product_test.rb 
    create  test/fixtures/products.yml 
    invoke resource_route 
    route resources :products 
    invoke scaffold_controller 
    create app/controllers/products_controller.rb 
    invoke erb 
    create  app/views/products 
    create  app/views/products/index.html.erb 
    create  app/views/products/edit.html.erb 
    create  app/views/products/show.html.erb 
    create  app/views/products/new.html.erb 
    create  app/views/products/_form.html.erb 
    invoke test_unit 
    create  test/controllers/products_controller_test.rb 
    invoke helper 
    create  app/helpers/products_helper.rb 
    invoke  test_unit 
    create  test/helpers/products_helper_test.rb 
    invoke jbuilder 
    create  app/views/products/index.json.jbuilder 
    create  app/views/products/show.json.jbuilder 
    invoke assets 
    invoke coffee 
    create  app/assets/javascripts/products.js.coffee 
    invoke scss 
    create  app/assets/stylesheets/products.css.scss 
    invoke scss 
    create app/assets/stylesheets/scaffolds.css.scss 

文件由active_record,scaffold_controller和test_unit創建可以在測試導致錯誤嘗試檢查他們,看看有沒有不應該的東西。

另請嘗試刪除development.sqlite3和test.sqlite3並再次運行rake db:migrate

還有一個rails destroy命令,將刪除所有自動生成的文件

+0

感謝您的意見,但我終於解決了問題 –