I have a Feature page that belongs to the Car page. That is working exactly how I want to, except for one thing.
After creating, updating or destroying, I want the
Here is a solution that also works with create_another
, using parent
and child
for model names.
This solution assumes that you show children as part of parent (e.g. via table_for
) so you do not need child's index
method.
In resource override controller's smart_resource_url
and index
methods:
controller do
def smart_resource_url
if create_another?
new_resource_url(create_another: params[:create_another])
else
parent_path(params[:parent_id])
end
end
def index
redirect_to parent_path(params[:parent_id])
end
end