Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.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_Ruby On Rails 3_Ruby On Rails 3.1 - Fatal编程技术网

Ruby on rails 模板缺少轨道

Ruby on rails 模板缺少轨道,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,我有三个模型一个 Customer Book Book_Managers id id id first description customer_id last book_manager_id visible email pas

我有三个模型一个

Customer               Book                 Book_Managers
id                     id                   id
first                  description          customer_id
last                   book_manager_id      visible
email                   
password                 
当客户访问customer#时,编辑它,然后将表格books和book#U Manager呈现为一个表格

在我的bookController中,我创建了一个book和book\u管理器

class BooksController < ApplicationController
    def create
        @customer = current_customer
        @book = @customer.book_managers.build(:visible => "true")
        @book = @customer.book_managers.first.books.build(:description => "2012")
    end
end

大多数情况下,在成功创建之后,您应该
重定向到带有成功消息的编辑或列表页面(
flash[:info]=“success”

所以你应该

def create
    @customer = current_customer
    @book = @customer.book_managers.build(:visible => "true")
    @book = @customer.book_managers.first.books.build(:description => "2012")
    flash[:info] = "Success"
    redirect_to :some_action
end

并在视图中以绿色显示
,例如:)

查看这些轨道和。他们将向您展示正确实现嵌套表单的方法。

我与他的问题是,他只会使用2模型,3模型深度是否相同?如果找不到视图零件,则会出现缺少模板错误。需要更多信息。。。保存图书信息后…它应该放在哪里。。。数据是否存储在3个表中?数据存储在2个表中,book for the description和book_manager知道其是否可见保存后,您不会重定向到任何视图。。。这就是问题所在。。。将重定向_添加到:action=>index
def create
    @customer = current_customer
    @book = @customer.book_managers.build(:visible => "true")
    @book = @customer.book_managers.first.books.build(:description => "2012")
    flash[:info] = "Success"
    redirect_to :some_action
end