Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 第页中的命名错误#联系_Ruby On Rails_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 第页中的命名错误#联系

Ruby on rails 第页中的命名错误#联系,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我犯了这个错误,我创建了pages模型,为pages controller创建了一个联系人,thank you and _表单页面。但是我得到了错误“页面中的NoMethodError#contact” `显示/home/rohit/Desktop/inertiaproject/inertiatwo/app/views/pages/_form.html.erb,其中第1行出现: NilClass:Class的未定义方法model_name pages\u controller.rb文件 clas

我犯了这个错误,我创建了pages模型,为pages controller创建了一个联系人,thank you and _表单页面。但是我得到了错误“页面中的NoMethodError#contact”

`显示/home/rohit/Desktop/inertiaproject/inertiatwo/app/views/pages/_form.html.erb,其中第1行出现:

NilClass:Class的未定义方法
model_name

pages\u controller.rb文件

class PagesController < ApplicationController


  def new
    @pages = pages.new
  end

  def create
    @pages = pages.new(params[:pages])
    if @pages.deliver
      render :thank_you
    else
      render :new
    end
  end

end
class PagesController
contact.html.erb

<h1>Want to get in touch?</h1>
<p>Please fill out the form below and we'll get back to you as soon as possible.</p>

<%= render 'form', :pages => @pages %>
想要联系吗?
请填写下表,我们会尽快回复您

@页面%>
_form.html.erb

<%= form_for pages do |f| %>
  <% if pages.errors.any? %>
    <ul>
      <% pages.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
    </ul>
  <% end %>

  <div style="display: none;">
    <%= f.label :nickname %><br/>
    <%= f.text_field :nickname %>
  </div>

  <div>
    <%= f.label :name %><br/>
    <%= f.text_field :name %>
  </div>

  <div>
    <%= f.label :email %><br/>
    <%= f.text_field :email %>
  </div>

  <div>
    <%= f.label :message %><br/>
    <%= f.text_area :message %>
  </div>

  <div>
    <%= f.submit "Send" %>
  </div>
<% end %>






好的,在您的控制器中开始型号以大写字母开始,并用作单数,因此
@pages=Page。新的
形式应该是
,请回答您自己的问题。