2012-06-08 29 views
6

Tôi nhận được một lỗi:Lỗi phần Thiếu trong Rails 3

Missing partial post/questions, application/questions with 
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. 
Searched in:* "/Users/..../<project name>/app/views" 

Tôi cố gắng để làm cho tất cả bài viết nào trong cơ sở dữ liệu để index.html.erb.

xem phần tôi là post/index.html.erb:

<!--html codes --> 

    <%= render 'questions' %> 

khiển controller/post_controller.rb: tên tập tin

def index 
     @posts=Post.all 
    end 

    def questions 
    end 

questions.html.erb

<%[email protected] do |post| %> 
    <table> 
     <tr> 
      <td> 
       <h2> 
        <%=post.title%> 
       </h2> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <h3><%=post.body%></h3> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       This Post comes under:<h4><%=post.tag%></h4> 
      </td> 
     </tr> 
    </table> 

Trả lời

17

Partials' phải bắt đầu bằng dấu gạch dưới. Bạn phải lưu _questions.html.erb trong thư mục bài đăng. Ngoài ra, bạn không cần phải xác định hành động 'câu hỏi'.

+0

thnks .... nó hoạt động. – Cyber

+0

không sao cả! xin vui lòng "chấp nhận" câu trả lời mặc dù. – cdesrosiers

+0

có vấn đề tương tự ... đã quên phần mở rộng .html.erb. .rb không làm việc lol –