Module: Stepper::ControllerAdditions::InstanceMethods

Defined in:
lib/stepper/controllers/controller_additions.rb

Instance Method Summary collapse

Instance Method Details

#createObject

controller create action it supports only html responce format for now



53
54
55
56
57
58
59
60
61
62
# File 'lib/stepper/controllers/controller_additions.rb', line 53

def create
  respond_to do |format|
    if @_stepper_resource_instance.save
      format.html { redirect_steps }
    else
      @_stepper_resource_instance.previous_step!
      format.html { render :action => "new" }
    end
  end
end

#newObject

controller new action it supports only html responce format for now



83
84
85
# File 'lib/stepper/controllers/controller_additions.rb', line 83

def new

end

#next_stepObject

controller new action it supports only html responce format for now



89
90
91
92
93
94
95
# File 'lib/stepper/controllers/controller_additions.rb', line 89

def next_step
  if @_stepper_resource_instance.last_step?
    redirect_to :action => :show, :id => @_stepper_resource_instance.id
  else
    render :action => :new
  end
end

#updateObject

controller update action it supports only html responce format for now



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/stepper/controllers/controller_additions.rb', line 66

def update
  @_stepper_resource_instance.previous_step!.previous_step! if params[:commit] == t('stepper.previous_step').html_safe

  @_stepper_resource_instance.previous_step! if params[:commit] == t('stepper.save').html_safe

  respond_to do |format|
    if @_stepper_resource_instance.save
      format.html { redirect_steps }
    else
      @_stepper_resource_instance.previous_step!
      format.html { render :action => "new" }
    end
  end
end