app/controllers/runs_controller.rb
# commit and confirm the result.
# default confirmation is to show history.
commit and confirm the result.
default confirmation is to show history.
commit and confirm the result . default confirmation is to show history .
def commit(action_name, &block)
    catch :flash_now do 
      @entity = yield
    end
    unless @entity
      render :update do |page|
        flash.now[:error] = "#{action_name}に失敗しました．"
        page.insert_html :top, "working_div" , :partial => "shared/flash_notice"
      end
      return false
    end
    flash.now[:notice] = @confirm_message || "#{action_name}に成功しました．"
    confirmation_method   = @confirmation_method   || "find_history"
    confirmation_template = @confirmation_template || "shared/history/run_history"
    render_response(confirmation_template) do send(confirmation_method) end
  rescue ActiveRecord::RecordInvalid => e 
    render_error_messages(e)
  end
def commit ( action_name , & block ) catch :flash_now do @entity = yield end unless @entity render :update do | page | flash . now [ :error ] = "#{action_name}に失敗しました．" page . insert_html :top , "working_div" , :partial => "shared/flash_notice" end return false end flash . now [ :notice ] = @confirm_message || "#{action_name}に成功しました．" confirmation_method = @confirmation_method || "find_history" confirmation_template = @confirmation_template || "shared/history/run_history" render_response ( confirmation_template ) do send ( confirmation_method ) end rescue ActiveRecord :: RecordInvalid => e render_error_messages ( e ) end
commit and confirm the result.
commit and confirm the result .
# when flash_now happened below, @entity is nil. # succeeded to commit # @confirmation_method and @confirmation_template can be set by yield above # this template can be changed in "find_history" as @commiting_template
action_name
<not_specific>
block
<not_specific>