Skip to content

Instantly share code, notes, and snippets.

@brandoncordell
Created July 25, 2011 00:52
Show Gist options
  • Save brandoncordell/1103321 to your computer and use it in GitHub Desktop.
Save brandoncordell/1103321 to your computer and use it in GitHub Desktop.
# jobs_controller
class JobsController < ApplicationController
def new
@job = Job.new
end
def create
@job = Job.new(params[:job])
@job.current_step = session[:listing_step]
if params[:back_button]
@job.previous_step
else
@job.next_step
end
session[:listing_step] = @job.current_step
render :action => 'new'
end
end
#job model
class Job < ActiveRecord::Base
attr_accessor :title, :description
attr_writer :current_step
def current_step
@current_step || steps.first
end
def next_step
self.current_step = steps[steps.index(current_step) + 1]
end
def previous_step
self.current_step = steps[steps.index(current_step) - 1]
end
def steps
%w[listing_details company_details preview_listing finish]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment