class Wallaby::ResourcesResponder
Resources responder
Public Instance Methods
to_csv()
click to toggle source
Render CSV with a file name that contains export timestamp.
# File lib/responders/wallaby/resources_responder.rb, line 9 def to_csv controller.headers['Content-Disposition'] = "attachment; filename=\"#{file_name_to_export}\"" default_render end
Protected Instance Methods
file_name_to_export()
click to toggle source
@return [String] file name with export timestamp
# File lib/responders/wallaby/resources_responder.rb, line 17 def file_name_to_export timestamp = Time.zone.now.to_s(:number) "#{request.params[:resources]}-exported-#{timestamp}.#{format}" end
has_errors?()
click to toggle source
@return [Boolean] true if there is exception or resource has errors @return [Boolean] false otherwise
# File lib/responders/wallaby/resources_responder.rb, line 24 def has_errors? # rubocop:disable Naming/PredicateName resource.nil? || resource.is_a?(Exception) || controller.decorate(resource).errors.present? end