3

我从来没有见过这样的错误,所以我什至不知道我的应用程序的哪些信息要与你分享。我将“地址”模型放入“客户模型”中。这是错误。(编辑)我使用SprintApp作为我的应用程序的指南。他们也有一个地址模型,他们的客户模型是我的客户模型。

ActionView::MissingTemplate in Admin/customers#new
  Showing /usr/local/rvm/gems/ruby-1.9.3-p392/bundler/gems/active_admin-fa7e4de2d5fa/app/views/active_admin/resource/new.html.arb where line #1 raised:
Missing partial admin/customers/form, active_admin/resource/form, active_admin/base/form, inherited_resources/base/form, application/form with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :arb, :coffee, :haml]}. Searched in:
  * "/Users/danielhatcher/rails/print/app/views"
  * "/usr/local/rvm/gems/ruby-1.9.3-p392/bundler/gems/active_admin-fa7e4de2d5fa/app/views"
  * "/usr/local/rvm/gems/ruby-1.9.3-p392/gems/kaminari-0.14.1/app/views"
  * "/usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.3/app/views"
Extracted source (around line #1):

1: insert_tag renderer_for(:new)
Rails.root: /Users/danielhatcher/rails/print

Application Trace | Framework Trace | Full Trace

我知道在不显示我的代码的情况下很难要求答案,但我们至少可以开始对话,我可以编辑和添加需要的内容。提前致谢。

客户控制器

    ActiveAdmin.register Customer do
    # Menu item
  menu :label => "Customers", :parent => "Administration"
      index do
        column :name
      end

    form :partial => "form"

  show :title => :name do
      panel "Client Details" do
          attributes_table_for resource do
            row :name
            row :email
            row :phone
            row :created_at do
              resource.created_at.humanize
            end
            row :updated_at do
              resource.updated_at.humanize
            end
          end
        text_node(render :partial => "addresses/show", :locals => { :address => resource.address })
      end
    end
end

客户_form

    <%=
semantic_form_for @customer, :builder => ActiveAdmin::FormBuilder do |f| 
  f.inputs "Customer Information" do 
    f.input :name 
        f.input :email
        f.input :phone
  render :partial => "addresses/form", :locals => { :form => f } 
  f.buttons 
end 
%>

地址_form

<%=
form.inputs "Address" do 
  form.semantic_fields_for :address do |address| 
    address.inputs :class => "" do 
      address.input :street 
      address.input :city 
      address.input :state, :as => :select, :collection => States::all.invert 
      address.input :zip, as: :string
    end 
  end 
end 
%>
4

2 回答 2

1

检查与指示相同的错误Kwent,解决方法如下:

另请参阅以下错误:

缺少部分 admin/customers/form、active_admin/resource/form、active_admin/base/form、inherited_resources/base/form、application/form with {:locale=>[:en], :formats=>[:html], : handlers=>[:erb, :builder, :arb, :coffee, :haml]}。

该错误还表明您缺少错误日志中列出的部分内容。

例如:

部分文件_form.html.erb应该在app/views/admin/customers文件夹中。对其他人也是如此。

<%= render :partial => "form" %>然后你应该在你的控制器中渲染你的部分:

希望对你有帮助!

于 2013-05-01T12:47:39.130 回答
0

当您说您在“客户”模型中放置“地址”模型时,我假设您的意思是表单,我假设这意味着您将两个表单放在同一个视图中?

无论哪种方式,我们都需要您尝试显示的视图以及调用控制器。我最初的猜测是你正在命名空间——类似于Admin::CustomersController,但你还没有运行生成器来从active_admin.

从未使用过active_admin,但根据文档,您是否尝试过运行以下命令?

rails generate active_admin:assets
于 2013-05-01T12:48:41.853 回答