2012-05-14 33 views
0

我不確定如何使用twitter引導標籤顯示模型的索引視圖。我有以下代碼,但它給了我一個缺失的模板錯誤。謝謝。使用twitter-bootstrap標籤顯示模型的索引視圖

application.html.erb

<ul id="myTab" class="nav nav-tabs"> 
    <li class="active"><a href="#home" data-toggle="tab">Home</a></li> 
    <li><a href="#profile" data-toggle="tab">Profile</a></li> 
</ul> 
<div id="myTabContent" class="tab-content"> 
    <div class="tab-pane fade in active" id="home"> 
    <p>Home...</p> 
    </div> 
    <div class="tab-pane fade" id="profile"> 
    <%= render :template => 'goals#index' %> 
    </div> 
</div> 

更新1:耙路線的顯示輸出

    goals GET /goals(.:format)     goals#index 
         POST /goals(.:format)     goals#create 
       new_goal GET /goals/new(.:format)    goals#new 
       edit_goal GET /goals/:id/edit(.:format)   goals#edit 
        goal GET /goals/:id(.:format)    goals#show 
         PUT /goals/:id(.:format)    goals#update 
         DELETE /goals/:id(.:format)    goals#destroy 

更新2:區域設置:錯誤輸出

缺少模板/目標#含{索引=> [:en],:formats => [:html],:handlers => [:erb,:builder,:coffee]}。搜查:

乾杯, Azren

從我可以看到你想要呈現一個控制器的索引動作,所以我建議在相應的視圖的目錄製作的index.html.erb

回答

0

好了,因爲它在視圖中搜索模板> controller_name> action.html.erb

如果您使用的是不是CRUD(Create,Read,Update Destroy)的動作,請確保將其添加到您的路線中.rb

resource :controller do 
    collection do 
    get 'action' 
    post 'action', path: "value" 
    end 
end 
+0

這是索引操作的CRUD操作之一。我已經用我的路線輸出更新了我的問題。 – Azren

+0

所以當你的控制器是目標,動作是索引時,你將需要添加一個文件來查看>目標> index.html.erb這是模板。現在在這個文件中輸入你需要在你的應用程序佈局的<%= yield %>方法中顯示的標記。 – dennis

+0

我確實有這個文件。如果我轉到http:// localhost:3000 /目標,它會正確顯示目標的索引視圖。還有什麼我錯過了?謝謝。 – Azren

相關問題