所以我一直把头撞在墙上,试图弄清楚为什么这不起作用。我不断得到
ActionView::Template::Error:
undefined method `admin_information_index_path' for #<#<Class:0x007fc67971cab8>:0x007fc67d775740>
随着跟踪:
# ./app/views/admin/informations/_form.html.erb:1:in `_app_views_admin_informations__form_html_erb__2815737811953353352_70245242566200'
# ./app/views/admin/informations/new.html.erb:2:in `_app_views_admin_informations_new_html_erb___3700624853666844924_70245242606040'
任何正确方向的提示?
我的路线:
namespace :admin do
resources :informations
end
我的控制器:
class Admin::InformationsController < Admin::AdminController
def new
@information = Information.new
end
end
意见/管理/信息/new.html.erb:
<h1>Add New Information Page</h1>
<%= render :partial => 'form', locals: { information: @information } %>
意见/管理/信息/_form.html.erb:
<%= form_for [:admin, information] do |f| %>
<%= error_messages_for information %>
<%= f.label :title %><br>
<%= f.text_field :title %><br><br>
<%= f.label :content %><br>
<%= f.text_area :content %><br><br>
<%= f.submit "Submit" %>
<% end %>
的输出rake routes
admin_informations GET /admin/informations(.:format) admin/informations#index
POST /admin/informations(.:format) admin/informations#create
new_admin_information GET /admin/informations/new(.:format) admin/informations#new
edit_admin_information GET /admin/informations/:id/edit(.:format) admin/informations#edit
admin_information GET /admin/informations/:id(.:format) admin/informations#show
PUT /admin/informations/:id(.:format) admin/informations#update
DELETE /admin/informations/:id(.:format) admin/informations#destroy
admin_root /admin(.:format) admin/sessions#new