2011-04-04 46 views
1

我是一位新的rails用戶,並試圖將回形針整合到我的應用程序第一次。在我的應用程序中點擊「新帖子」按鈕時,出現以下錯誤消息,此時基本上是博客。任何幫助深表感謝!整合回形針

SyntaxError in Posts#new 

Showing /Users/blanecordes/rails_projects/BoxScoreBuzz/app/views/posts/_form.html.erb where line #1 raised: 

compile error 
/Users/blanecordes/rails_projects/BoxScoreBuzz/app/views/posts/_form.html.erb:1: syntax error, unexpected tASSOC, expecting kEND 
...end= form_for(@post), :html=> {:multipart => true} do |f| @... 
          ^
/Users/blanecordes/rails_projects/BoxScoreBuzz/app/views/posts/_form.html.erb:1: syntax error, unexpected kDO, expecting kEND 
...html=> {:multipart => true} do |f| @output_buffer.safe_conca... 
          ^
/Users/blanecordes/rails_projects/BoxScoreBuzz/app/views/posts/_form.html.erb:35: syntax error, unexpected kENSURE, expecting $end 
Extracted source (around line #1): 

1: <%= form_for(@post), :html=> {:multipart => true} do |f| %> 
2: <% if @post.errors.any? %> 
3:  <div id="error_explanation"> 
4:  <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> 

這是我目前_form.html.erb代碼

<%= form_for(@post), :html=> {:multipart => true} do |f| %> 
    <% if @post.errors.any? %> 
    <div id="error_explanation"> 
     <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> 

     <ul> 
     <% @post.errors.full_messages.each do |msg| %> 
     <li><%= msg %></li> 
     <% end %> 
     </ul> 
    </div> 
    <% end %> 

    <div class="field"> 
    <%= f.label :name %><br /> 
    <%= f.text_field :name %> 
    </div> 
    <div class="field"> 
    <%= f.label :title %><br /> 
    <%= f.text_field :title %> 
    </div> 
    <div class="field"> 
    <%= f.label :content %><br /> 
    <%= f.text_area :content %> 
    </div> 
    <div class="field"> 
    <%= f.label 'Photo' %><br /> 
    <%= f.file_field :photo %><br /> 
    </div> 
<div class="actions"> 
    <%= f.submit %> 
    </div> 
<% end %> 

回答

4

嘗試改變的第一行_form.html.erb到:

<%= form_for(@post, :html=> {:multipart => true}) do |f| %> 
+0

固定它,謝謝! – BC00 2011-04-07 01:22:57