Skip to content

Instantly share code, notes, and snippets.

@criscokid
Forked from pc-skinny/edit_states.js.erb
Created June 10, 2013 19:06
Show Gist options
  • Save criscokid/5751316 to your computer and use it in GitHub Desktop.
Save criscokid/5751316 to your computer and use it in GitHub Desktop.
$('#states').html("")
def edit_states
@job = Job.find(params[:id])
@assigned_states = @job.states.order(:name)
state_ids = @job.states.map(&:id)
if state_ids.present?
@unassigned_states = State.where('id NOT IN (?)', state_ids ).order(:name)
else
@unassigned_states = State.all
end
respond_with(@job)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment