2

I have two models :

Project

has_one :abstract

Abstract

belongs_to :project

After reading the active admin documentation I do this :

member_action :abstracts do
    @project = Project.find(params[:id])
    @abstract = @project.abstract
end

Then I create an abstracts.html.arb in admin/project and I can access to it by this url /admin/projects/:id/abstracts

My question is how can I add the form to create/edit/delete/show abstract from here ?

Awea
  • 3,163
  • 8
  • 40
  • 59

1 Answers1

1

You can use this syntax to render forms (Source):

render active_admin_template('edit.html.arb'), :layout => false

But according code you provided - you should use belongs_to syntax from inherited resources.

Belongs to

Finally, our Projects are going to get some Tasks. Then you create a TasksController and do:

class TasksController < InheritedResources::Base
  belongs_to :project
end

belongs_to accepts several options to be able to configure the association. For example, if you want urls like /projects/:project_title/tasks, you can customize how InheritedResources find your projects:

class TasksController < InheritedResources::Base
  belongs_to :project, :finder => :find_by_title!, :param => :project_title
end

Active Admin is based on it, so it should work. Documentation.

Community
  • 1
  • 1
brain-geek
  • 185
  • 9