我从未见过这样的错误,所以我什至不知道我的应用程序的哪些信息可以与您分享。我将“地址”模型放入“客户模型”中。这是错误。 (编辑)我正在使用 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
客户_表格
<%=
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
%>
最佳答案
检查 same error如 Kwent
所示解决方法如下:
同时看到如下错误:
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]}.
该错误还表明您缺少错误日志中列出的部分内容。
例如:
部分文件_form.html.erb
应该在 app/views/admin/customers
文件夹。
其他人也一样。
然后你应该像这样渲染你的部分:<%= render :partial => "form" %>
在你的 Controller 中。
希望对您有所帮助!
关于ruby-on-rails - 将模型放入另一个模型时缺少部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16318163/