lib/padrino-responders/default.rb
##
# Default response for savings, similar to destroy response allow to store
# redirection after success and also have automatically generated and translated 
# flash messages. When action is successfully executed then we will see 
# redirection or default views for html and js, and serialized object for 
# other formats. Otherwise we will see default form view or serialized errors. 
# 
Default response for savings, similar to destroy response allow to store
redirection after success and also have automatically generated and translated
flash messages. When action is successfully executed then we will see
redirection or default views for html and js, and serialized object for
other formats. Otherwise we will see default form view or serialized errors.
Default response for savings similar to destroy response allow to store redirection after success and also have automatically generated and translated flash messages . When action is successfully executed then we will see redirection or default views for html and js and serialized object for other formats . Otherwise we will see default form view or serialized errors .
def default_response_for_save(kind, object, location=nil)
          valid                = false
          valid                = object.valid? if object.respond_to?(:valid?)
          default_success_view = "#{controller_name}/#{action_name}"
          default_form_view    = "#{controller_name}/#{kind}"
          object_notice        = "responder.messages.#{controller_name}.#{action_name}"
          alternative_notice   = "responder.messages.default.#{action_name}"
          if valid 
            case content_type
            when :html
              if location
                notify(:notice, t(object_notice, 
                  :model   => human_model_name(object),
                  :default => t(alternative_notice, human_model_name(object))
                  ))
                redirect location
              else
                render default_success_view 
              end
            when :js
              render default_success_view
            else
              render content_type, object, :location => location
            end
          else
            if [:html, :js].include?(content_type)
              render default_form_view
            else
              errors = false
              errors = object.errors if object.respond_to?(:errors)
              render content_type, errors, :status => :unprocessible_entity
            end
          end
        end
def default_response_for_save ( kind , object , location = nil ) valid = false valid = object . valid? if object . respond_to? ( :valid? ) default_success_view = "#{controller_name}/#{action_name}" default_form_view = "#{controller_name}/#{kind}" object_notice = "responder.messages.#{controller_name}.#{action_name}" alternative_notice = "responder.messages.default.#{action_name}" if valid case content_type when :html if location notify ( :notice , t ( object_notice , :model => human_model_name ( object ) , :default => t ( alternative_notice , human_model_name ( object ) ) ) ) redirect location else render default_success_view end when :js render default_success_view else render content_type , object , :location => location end else if [ :html , :js ] . include? ( content_type ) render default_form_view else errors = false errors = object . errors if object . respond_to? ( :errors ) render content_type , errors , :status => :unprocessible_entity end end end
Default response for savings, similar to destroy response allow to store
redirection after success and also have automatically generated and translated
flash messages.
Default response for savings similar to destroy response allow to store redirection after success and also have automatically generated and translated flash messages .
kind
<not_specific>
object
<not_specific>
location
<not_specific>