Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 36 additions & 18 deletions lib/auxiliary_rails/concerns/resourceable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down