2013-07-07 21 views
0

下午好,下面的Ruby教程,用的form_for

我開始接觸軌和我在http://guides.rubyonrails.org/getting_started.html以下引導問題我似乎已經打了一個路障。

當我嘗試使用的form_for輔助傳遞數組作爲參數(如在引導件的部分6.4解釋)我得到以下錯誤

顯示[mypath中] /應用/視圖/帖/ show.html.erb其中第11行提出:

[MyPath] /app/models/comment.rb:3:語法錯誤,意外的keyword_end,?預計$結束

所呈現的視圖的代碼是

<p> 
    <strong>Title:</strong> 
    <%= @post.title %> 
</p> 

<p> 
    <strong>Text:</strong> 
    <%= @post.text %> 
</p> 

<%= form_for([@post, @post.comments.build]) do |f| %> 
    <p> 
    <%= f.label :commenter %><br /> 
    <%= f.text_field :commenter %> 
    </p> 
    <p> 
    <%= f.label :body %><br /> 
    <%= f.text_area :body %> 
    </p> 
    <p> 
    <%= f.submit %> 
    </p> 
<% end %> 

<%= link_to 'Back', posts_path %> 
| <%= link_to 'Edit', edit_post_path(@post) %> 

這是樁模型看起來像

class Post < ActiveRecord::Base 
    has_many :comments 
    validates :title, presence: true, 
      length: { minimum: 5 } 

end 

,這是什麼註釋模型的樣子

Class Comment < ActiveRecord::Base 
    belongs_to :post 
end 

什麼可能導致這是起訴? 「結束」標籤似乎正確匹配。

只是爲了額外的信息,如果有必要

紅寶石-v

紅寶石1.9.3p429(2013年5月15日修訂40747)x86_64的-darwin12.3.0]

軌-v

的Rails 4.0.0

感謝FO任何幫助。我不確定是否需要更多信息,但請隨時通知我。

+0

什麼就行#3? –

+1

我剛剛意識到問題在於評論模型被聲明爲Class而不是Class。這是造成這個問題的原因。 – user2557427

+0

是的,我也發現並把它放在答案中。 –

回答

0

錯字就在這裏 -

Class Comment <應該class Comment <