我有一个activeadmin rails 5应用程序,即使显示路由,我也会收到无路由匹配错误。
new_admin_cohort GET /admin/cohorts/new(.:format)
admin/cohorts#new
edit_admin_cohort GET /admin/cohorts/:id/edit(.:format)
admin/cohorts#edit
admin_cohort GET /admin/cohorts/:id(.:format)
admin/cohorts#show
PATCH /admin/cohorts/:id(.:format)
admin/cohorts#update
PUT /admin/cohorts/:id(.:format)
admin/cohorts#update
DELETE /admin/cohorts/:id(.:format)
admin/cohorts#destroy
batch_action_admin_cohort_genius POST /admin/cohorts/:cohort_id/genius/batch_action(.:format) admin/genius#batch_action
admin_cohort_genius GET /admin/cohorts/:cohort_id/genius(.:format) admin/genius#index
POST /admin/cohorts/:cohort_id/genius(.:format) admin/genius#create
new_admin_cohort_geniu GET /admin/cohorts/:cohort_id/genius/new(.:format) admin/genius#new
edit_admin_cohort_geniu GET /admin/cohorts/:cohort_id/genius/:id/edit(.:format) admin/genius#edit
admin_cohort_geniu GET /admin/cohorts/:cohort_id/genius/:id(.:format) admin/genius#show
PATCH /admin/cohorts/:cohort_id/genius/:id(.:format) admin/genius#update
PUT /admin/cohorts/:cohort_id/genius/:id(.:format) admin/genius#update
DELETE /admin/cohorts/:cohort_id/genius/:id(.:format) admin/genius#destroy
我正在尝试将用户资源嵌套在Cohort资源下,在那里我可以共同创建用户和同一个群组或一个群组和一个群组内的多个用户(到目前为止还无法做到)
ActiveAdmin.register User do
belongs_to :cohort, :finder => :find_by_resource_key!#optional: true
permit_params :avatar, :name, :classroom_id, :first_name, :cohort, :last_name,
:username, :email, :email2, :cell, :password, :password_confirmation,
:stipend, :address, :benchmarks, :genius, :attendance_id, :users_id,
:cohort_id, :city, :projects_attributes, avatar_attributes: [:_destroy]
config.batch_actions = true
menu priority: 4
duplicable?
controller do
def find_resource
User.find_by(resource_key: params[:id])
end
end
index do
selectable_column
id_column :cohort_id
column :first_name
column :last_name
column :email
column :email2
column :username
column :address
column :cell
column :projects
column :sign_in_count
column :created_at
image_column :avatar, style: :thumb
actions
end
form do |f|
f.inputs do
f.semantic_errors *f.object.errors.keys
f.input :genius
f.input :cohort_id
f.input :city
f.input :cell
f.input :email
f.input :password, input_html: { autocomplete: "new-password" }
f.input :email2
f.input :username
f.input :avatar, as: :file
if f.object.avatar.present?
f.semantic_fields_for :avatar_attributes do |avatar_fields|
avatar_fields.input :_destroy, as: :boolean, label: 'Delete?'
end
end
f.inputs 'Projects' do
f.has_many :projects, allow_destroy: true,
new_record: true do |u|
u.input :app_name
u.input :coding
u.input :project_details
u.input :start_date
u.input :github
#end
end
f.actions
end
end
end
end
ActiveAdmin.register Cohort do
permit_params :city, :cohort_id, :genius, users_attributes: [:last_name, :users_id, :cohort, :username, :genius, :cohort_id, :city, :email, :email2, :cell, :stipend, :project], attendances_attributes: [:present, :absent, :halfday, :class_date], classroom_attributes: [:id, :body, :_destroy]
menu priority: 3
config.batch_actions = true
duplicable?
#active_admin_importable
sortable tree: true
form do |f|
f.inputs 'Hgp Cohorts', :body
f.inputs do
f.input :city, label: "Office Location"
f.input :cohort, label: "Cohort Number"
end
f.inputs "Geniuses" do
f.has_many :users,allow_destroy: true,
new_record: false do |a|
a.input :genius
a.input :cell
a.input :email
a.input :password, input_html: { autocomplete: "new-password" }
a.input :email2
a.input :username
a.input :avatar, as: :file
if user.object.avatar.present?
uuser.semantic_fields_for :avatar_attributes do |avatar_fields|
avatar_fields.input :_destroy, as: :boolean, label: 'Delete?'
end
end
end
end
f.actions
end
index do
selectable_column
id_column
column :city
column :cohort
actions
end