Skip to content

Instantly share code, notes, and snippets.

@matthodan
Created February 13, 2011 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthodan/824557 to your computer and use it in GitHub Desktop.
Save matthodan/824557 to your computer and use it in GitHub Desktop.
jobs_controller.rb
class JobsController < ApplicationController
before_filter :require_user
ssl_required :index, :new, :create, :update, :destroy, :destroy_all
respond_to :html, :only => [:index, :new, :create, :destroy, :destroy_all]
respond_to :json, :only => [:index, :create, :update, :destroy]
[... omitted ...]
def create
@job = Job.new(params[:job])
@job.user = current_user
@job.update_status!
if @job.save
flash[:success] = 'New job created'
@job.enqueue_http_request! :target, @job.run_at
respond_with(@job) do |f|
f.html { redirect_to jobs_path }
f.json { render 'jobs/job.json.erb' }
end
else
respond_with(@job) do |f|
f.html { render :action => 'new' }
f.json { render 'jobs/error.json.erb' }
end
end
end
[... omitted ...]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment