Skip to content

Instantly share code, notes, and snippets.

@natemartinsf
Created December 14, 2009 05:19
Show Gist options
  • Save natemartinsf/255808 to your computer and use it in GitHub Desktop.
Save natemartinsf/255808 to your computer and use it in GitHub Desktop.
class JobPostingsController < ApplicationController
# GET /job_postings
# GET /job_postings.xml
# GET /job_postings.json
def index
@job_postings = JobPosting.all
respond_to do |format|
#format.html # index.html.erb
format.json { render :json => @job_postings }
end
end
# GET /job_postings/1
# GET /job_postings/1.xml
# Get /job_postings/1.json
def show
@job_posting = JobPosting.find(params[:id])
respond_to do |format|
#format.html # show.html.erb
format.json { render :json => @job_posting }
end
end
# GET /job_postings/new
# GET /job_postings/new.xml
# GET /job_postings/new.json
def new
@job_posting = JobPosting.new
respond_to do |format|
#format.html # new.html.erb
format.json { render :json => @job_posting }
end
end
# GET /job_postings/1/edit
def edit
@job_posting = JobPosting.find(params[:id])
end
# POST /job_postings
# POST /job_postings.xml
# POST /job_postings.json
def create
@job_posting = JobPosting.new(params[:job_posting])
respond_to do |format|
if @job_posting.save
flash[:notice] = 'JobPosting was successfully created.'
#format.html { redirect_to(@job_posting) }
format.json { render :json => @job_posting, :status => :created, :location => @job_posting }
else
#format.html { render :action => "new" }
format.json { render :json => @job_posting.errors, :status => :unprocessable_entity }
end
end
end
# PUT /job_postings/1
# PUT /job_postings/1.xml
# PUT /job_postings/1.json
def update
@job_posting = JobPosting.find(params[:id])
respond_to do |format|
if @job_posting.update_attributes(params[:job_posting])
flash[:notice] = 'JobPosting was successfully updated.'
#format.html { redirect_to(@job_posting) }
format.json { head :ok }
else
#format.html { render :action => "edit" }
format.json { render :json => @job_posting.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /job_postings/1
# DELETE /job_postings/1.xml
# DELETE /job_postings/1/json
def destroy
@job_posting = JobPosting.find(params[:id])
@job_posting.destroy
respond_to do |format|
#format.html { redirect_to(job_postings_url) }
format.json { head :ok }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment