<%= @ request.query.inspect%>为nil调出未定义的方法`query':NilClass(NoMethodError)

时间:2013-02-22 06:02:26

标签: ruby

嘿伙计们,我正在通过schneems做这个课程 https://github.com/Stephenitis/ruby_view_server(见自述)

我进入第6步)与您的服务器交谈,我打算添加<%= @ request.query.inspect%>

当我运行$ ruby​​ page_generator_with_layout.rb

我收到此错误

  - Converting .html.erb to html with Layout !!!
(erb):14:in `process_erb': undefined method `query' for nil:NilClass (NoMethodError)
    from /Users/Jupitor/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/erb.rb:838:in `eval'
    from /Users/Jupitor/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/erb.rb:838:in `result'
    from page_generator_with_layout.rb:6:in `process_erb'
    from page_generator_with_layout.rb:24:in `block in <main>'
    from page_generator_with_layout.rb:13:in `each'
    from page_generator_with_layout.rb:13:in `<main>'

1 个答案:

答案 0 :(得分:1)

您不再需要运行$ ruby​​ page_generator_with_layout.rb,因为服务器直接查看视图(.html.erb文件),但不是.html; (纠正我,如果我错了,因为我现在正在做这个练习,并且早些时候犯了同样的错误)