Gemfile
-
Edit
Gemfile
as such- gem 'osc-machete', '~> 0.6.3' + gem 'osc-machete', '~> 1.0' + gem 'osc_machete_rails', '~> 1.0' - gem 'awesim_rails', '~> 0.8' + gem 'awesim_rails', '~> 1.0'
-
Run
$ bundle install --local
Development Environment
-
Edit
config/environments/development.rb
as such- config.eager_load = false + config.eager_load = true
Models
Workflow Model
No changes necessary.
Job Model
-
Edit
app/models/job.rb
as suchclass Job < ActiveRecord::Base - include OSC::Machete::SimpleJob::Statusable + include OscMacheteRails::Statusable ... - before_destroy { |j| j.job.delete(rmdir: true) } ... end
Controllers
-
Edit any
app/controllers/*_controller.rb
as suchdef destroy - @container.destroy respond_to do |format| - format.html { redirect_to containers_url } - format.json { head :no_content } + if @container.destroy + format.html { redirect_to containers_url, notice: 'Container was successfully destroyed.' } + format.json { head :no_content } + else + format.html { redirect_to containers_url, alert: "Container failed to be destroyed: #{@container.errors.to_a}" } + format.json { render json: @container.errors, status: :internal_server_error } + end end end
def submit - if @container.submitted? - respond_to do |format| - format.html { redirect_to containers_url, alert: 'Container simulation has already been submitted!' } + respond_to do |format| + if @container.submitted? + format.html { redirect_to containers_url, alert: 'Container has already been submitted.' } format.json { head :no_content } - end - else - #TODO: add error handling - @container.submit - - respond_to do |format| - format.html { redirect_to containers_url, notice: 'Container simulation submitted.' } + elsif @container.submit + format.html { redirect_to containers_url, notice: 'Container was successfully submitted.' } format.json { head :no_content } + else + format.html { redirect_to containers_url, alert: "Container failed to be submitted: #{@container.errors.to_a}" } + format.json { render json: @container.errors, status: :internal_server_error } end end end
-
Replace any occurrence of
container
above with your respective workflow model name.
Helpers
-
Edit any
app/helpers/*_helper.rb
as such- def job_status_label(job) - ... - end
Basically, remove the method
job_status_label
from all of your helpers as it is now provided for you.
Gotchas
-
simulation.status
andjob.status
now return anOSC::Machete::Status
valuejob.status #=> OSC::Machete::Status.queued
although this still maintains backwards compatibility, one should be careful about comparisons with single letter characters
def queued? status == "Q" end