rapid-psychiatrist-19805
07/20/2023, 4:18 PMloud-jewelry-99127
07/20/2023, 4:40 PMafter_create_path
option on the resource only accept :show
(default), :edit
, or :index
. However there is another approach to handle this. We let there some hooks on the controllers (I recommend to give a quick view on all of them here https://docs.avohq.io/2.0/controllers.html).
There is several hooks that you can use to achieve the wanted behavior, for example if you want to get more control over the response after a record creation you can override the create_success_action
(https://docs.avohq.io/2.0/controllers.html#create_success_action)
Something like this (I'll use the post
model on my examples)
ruby
class Avo::PostsController < Avo::ResourcesController
def create_success_action
respond_to do |format|
format.html { redirect_to new_resources_post_path, notice: create_success_message}
end
end
end
Notice that the only thing that I changed was the path from the redirect, if you don't want to change the action but only the path there is actually another hook, after_create_path
(https://docs.avohq.io/2.0/controllers.html#after_create_path)
ruby
class Avo::PostsController < Avo::ResourcesController
def after_create_path
new_resources_post_path
end
end
TL;DR
In the avo controller hook into the after_create_path
overriding that method and returning the resource creation pagerapid-psychiatrist-19805
07/20/2023, 4:46 PMloud-jewelry-99127
07/20/2023, 4:51 PMrapid-psychiatrist-19805
07/20/2023, 4:54 PMrapid-psychiatrist-19805
07/20/2023, 4:57 PMloud-jewelry-99127
07/20/2023, 5:03 PMlemon-wall-20836
07/21/2023, 6:08 AMself.create_and_another = true
option that would add a button like that to a resource 💪