diff --git a/lib/auxiliary_rails/concerns/resourceable.rb b/lib/auxiliary_rails/concerns/resourceable.rb index 01a6e65..3229798 100644 --- a/lib/auxiliary_rails/concerns/resourceable.rb +++ b/lib/auxiliary_rails/concerns/resourceable.rb @@ -189,33 +189,51 @@ def new_resource_path # redirects def redirect_after_create - if flash[:notice].blank? - flash[:notice] = t('create.notice', - resource_name: resource_class.model_name.human, - scope: i18n_scope) - end + flash[:notice] ||= redirect_after_create_message + + redirect_to redirect_after_create_path + end + + def redirect_after_create_message + t('create.notice', + resource_name: resource_class.model_name.human, + scope: i18n_scope) + end - redirect_to resource_path(resource) + def redirect_after_create_path + resource_path(resource) end def redirect_after_update - if flash[:notice].blank? - flash[:notice] = t('update.notice', - resource_name: resource_class.model_name.human, - scope: i18n_scope) - end + flash[:notice] ||= redirect_after_update_message + + redirect_to redirect_after_update_path + end - redirect_to resource_path(resource) + def redirect_after_update_message + t('update.notice', + resource_name: resource_class.model_name.human, + scope: i18n_scope) + end + + def redirect_after_update_path + resource_path(resource) end def redirect_after_destroy - if flash[:notice].blank? - flash[:notice] = t('destroy.notice', - resource_name: resource_class.model_name.human, - scope: i18n_scope) - end + flash[:notice] ||= redirect_after_destroy_message + + redirect_to redirect_after_destroy_path + end + + def redirect_after_destroy_message + t('destroy.notice', + resource_name: resource_class.model_name.human, + scope: i18n_scope) + end - redirect_to collection_path + def redirect_after_destroy_path + collection_path end # system