I want to customize following things
Yes, it is possible.
Actions Name like "Add User" => "Create User", "Edit User" => "Update User" etc
Instead of having f.actions
, you could have
<%= f.actions do %>
<%= f.action :submit, as: :button, label: 'Create User' %>
<%= f.action :cancel, as: :link %> # change it to button if needed
<% end %>
ActiveAdmin uses formtastic, read more here.
Success Message On Delete, Create and Edit like "user successfully created" => "customer successfully created"
def create # or any other action
super do |format| # this is important - override the original implementation
redirect_to(
admin_users_path,
notice: 'Your custom message for successful user creation'
) and return
end
end
You could also try this:
def create # or any other action
super do |format| # this is important - override the original implementation
flash[:notice] = 'Your custom message for successful user creation'
# you do understand, that if you have different routes you should change this, right?
redirect_to admin_users_path
end
end
Add A Create Button On Show Page beside edit and delete
action_item only: :show do
link_to 'Create new user', new_admin_users_path
end
I am adding answer for second(refrence from above), But On validation errors above is not working so i customize it which can help you better
controller do
def update
super do |format|
if !@your_object.errors.any?
redirect_to(
admin_my_localities_path,
notice: 'custom message.'
) and return
end
end
end
def destroy
super do |format|
if !@your_object.errors.any?
redirect_to(
admin_my_localities_path,
notice: 'custom message.'
) and return
else
redirect_to(
admin_my_localities_path,
alert: 'custom error.'
) and return
end
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With