Reputation: 7493
I'm working on an application where users can create requests for car maintenance services from a company. Users log on and create a request. The request contains details of the car that would be sent in as well as an assumption on the customers part on what the problem might be.
A request can have details for one or infinite cars. There would be a table for requests and a table for cars and most importantly a car trouble table of the forms:
CAR
ID | DETAILS
REQUEST
ID|CUSTOMERID|DETAILS
CAR_TROUBLE_REQUEST
ID|CARID|REQUEST_ID|TROUBLE_DETAILS|PICKUPDATE|PICKUPPOINT
I need to build using activeadmin a custom form and handler that would do the following:
Take in basic detail of the car (check if a car by the registration number exists then use that car else make an entry and use it)
Take in details of the issue facing the car.
For this to work it has to make entries in three tables - now I've set up basic models for all three tables and even have the form created however using activeadmin how do I handle the submitted form?
Please help!
Upvotes: 1
Views: 5492
Reputation: 6720
In the docs http://activeadmin.info/docs/8-custom-actions.html#rendering_in_custom_actions you can find the following example:
ActiveAdmin.register Post do
# /admin/posts/:id/comments
member_action :comments do
@post = Post.find(params[:id])
# This will render app/views/admin/posts/comments.html.erb
end
end
Inside app/views/admin/posts/comments.html.erb
file you can define your own form.
With another code snippet - http://activeadmin.info/docs/8-custom-actions.html#member_actions you can define correspond form's action.
Upvotes: 1