Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.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 3 rails嵌套表单找不到子模型的方法_Ruby On Rails 3_Activerecord_Nested Forms - Fatal编程技术网

Ruby on rails 3 rails嵌套表单找不到子模型的方法

Ruby on rails 3 rails嵌套表单找不到子模型的方法,ruby-on-rails-3,activerecord,nested-forms,Ruby On Rails 3,Activerecord,Nested Forms,我有两种型号servicio和caja 塞维西奥,有很多:卡哈 Caja,属于:servicio 但是我找不到servicio.cajas方法,因为某种原因,我可以找到servicio.caja-tho。我遗漏了什么吗?我需要提供更多信息吗 来自日志的消息 00:04:57 ActionView::Template::Error (undefined method `cajas' for #<Servicio:0x00000004ae55e8>): 1: <%= form_f

我有两种型号servicio和caja

塞维西奥,有很多:卡哈 Caja,属于:servicio

但是我找不到servicio.cajas方法,因为某种原因,我可以找到servicio.caja-tho。我遗漏了什么吗?我需要提供更多信息吗

来自日志的消息

 00:04:57 ActionView::Template::Error (undefined method `cajas' for #<Servicio:0x00000004ae55e8>):
1: <%= form_for([@servicio, @servicio.cajas.new]) do |f| %>
2:   <div class="field">
3:     <%= f.label :tipo_id %><br />
4:     <%= f.text_field :tipo_id %>
app/views/cajas/new.html.erb:1:in `_app_views_cajas_new_html_erb___4360865893086628466_37227020_2289718708193017139'
app/views/servicios/show.html.erb:68:in `_app_views_servicios_show_html_erb__559030007672389687_39240460_2289718708193017139'
app/controllers/servicios_controller.rb:18:in `show'

我找到了根本原因。我在定义has\u many:cajas时出错,我以前有has\u many:caja。

无需回答此问题,我找到了根,我将添加答案。