Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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 未定义的方法';型号名称';对于NilClass:heroku上的子类出现类错误_Ruby On Rails_Ruby_Ruby On Rails 3_Heroku - Fatal编程技术网

Ruby on rails 未定义的方法';型号名称';对于NilClass:heroku上的子类出现类错误

Ruby on rails 未定义的方法';型号名称';对于NilClass:heroku上的子类出现类错误,ruby-on-rails,ruby,ruby-on-rails-3,heroku,Ruby On Rails,Ruby,Ruby On Rails 3,Heroku,我只是在开始阶段建立我的应用程序-所以没有什么太严重的在这里。它在我当地的环境中工作得很好,但似乎在heroku上崩溃了 代码是这样的: <%= form_for(@reader, :url => user_registration_path) do |f| %> <div><%= f.label :email %><br /> <%= f.email_field :email, :autofocus => true %

我只是在开始阶段建立我的应用程序-所以没有什么太严重的在这里。它在我当地的环境中工作得很好,但似乎在heroku上崩溃了

代码是这样的:

<%= form_for(@reader, :url => user_registration_path) do |f| %>

  <div><%= f.label :email %><br />
  <%= f.email_field :email, :autofocus => true %></div>

  <div><%= f.label :password %><br />
  <%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation %></div>

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

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

  <div><%= f.submit "Sign up" %></div>
<% end %>
我在Desive中有一个用户模型。 我在User、Authors和Readers下有2个子类

用于添加读取器的表单如下所示:

<%= form_for(@reader, :url => user_registration_path) do |f| %>

  <div><%= f.label :email %><br />
  <%= f.email_field :email, :autofocus => true %></div>

  <div><%= f.label :password %><br />
  <%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation %></div>

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

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

  <div><%= f.submit "Sign up" %></div>
<% end %>
这个模型很简单:

Class Reader < User
end
类读取器
虽然我还没有尝试使用表单创建新用户,但在本地环境中加载页面时没有遇到任何错误。然而在heroku上,我得到了NilClass:Class的
未定义的方法“model\u name”

我已经搜索了数据库,并重新启动了服务器,但运气不好


有什么想法吗?

我看@reader还没有设置好。 表单不在index.html.erb中。
它必须是“新建”和“编辑”操作使用的部分_form.html.erb。因此,您必须在readers控制器中的那些操作中设置@reader,您不觉得使用
用户注册路径
作为
reader
模型表单的操作是错误的吗?首先要放弃明显的:该表单在index.html.erb中吗?看起来@reader没有设置。@fotanus,最初是的-但它将存在于用户表中,并且不会在本地给我任何错误。所以我不明白为什么这会是heroku的问题。打得好-打得不好,我没有意识到我的观点是错误的,请随意将其作为答案发布-我将标记为correct@Ghar