Created
February 13, 2011 09:13
-
-
Save matthodan/824557 to your computer and use it in GitHub Desktop.
jobs_controller.rb
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
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