Created
July 25, 2011 00:52
-
-
Save brandoncordell/1103321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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