iloveyou

初学ror,使用官方那个blog例子,卡在这里了,求指点。我用rails 3.1.3

  •  
  •   iloveyou · Jan 17, 2012 · 5113 views
    This topic created in 5230 days ago, the information mentioned may be changed or developed.
    Showing /Users/Sites/blog/app/views/posts/show.html.erb where line #21 raised:

    undefined local variable or method `comment' for #<#<Class:0x007fc394660120>:0x007fc394663aa0>
    Extracted source (around line #21):

    18: <% @post.comments.each do |commnet| %>
    19: <p>
    20: <b>Commenter:</b>
    21: <%= comment.commenter%>
    22: </p>
    23: <p>
    24: <b>Comment:</b>
    5 replies    1970-01-01 08:00:00 +08:00
    iloveyou
        1
    iloveyou  
    OP
       Jan 17, 2012
    posts model:

    class Post < ActiveRecord::Base
    validates :name, :presence => true
    validates :title, :presence => true, :length => { :minimum => 5 }

    has_many :comments
    end


    comments model:

    class Comment < ActiveRecord::Base
    belongs_to :post
    end
    iloveyou
        2
    iloveyou  
    OP
       Jan 17, 2012
    posts model:

    class Post < ActiveRecord::Base
    validates :name, :presence => true
    validates :title, :presence => true, :length => { :minimum => 5 }

    has_many :comments
    end


    comments model:

    class Comment < ActiveRecord::Base
    belongs_to :post
    end
    pepsin
        3
    pepsin  
       Jan 17, 2012
    21行那个comment没有对应的实例变量或者是方法吧?
    goophy
        4
    goophy  
       Jan 17, 2012 via iPhone
    18: <% @post.comments.each do |commnet| %>
    拼写错误 commnet -> comment
    iloveyou
        5
    iloveyou  
    OP
       Jan 18, 2012
    @goophy 我晕,我思索几天的问题啊,2b青年啊我
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3840 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 10:25 · PVG 18:25 · LAX 03:25 · JFK 06:25
    ♥ Do have faith in what you're doing.