Navigation Menu

Skip to content

Commit

Permalink
made controller changes to jobProspects controller
Browse files Browse the repository at this point in the history
  • Loading branch information
kerrieyee committed Feb 2, 2013
1 parent 408c7b0 commit 100f5f5
Showing 1 changed file with 17 additions and 36 deletions.
53 changes: 17 additions & 36 deletions app/controllers/job_prospects_controller.rb
@@ -1,72 +1,53 @@
class JobProspectsController < ApplicationController
respond_to :json
def index
@job_prospects = JobProspect.paginate(:page => params[:page],
:per_page => 8,
:order => 'created_at DESC',
:conditions => { :user_id => current_user.id })
@job_prospect=JobProspect.new
respond_with (@job_prospects)
end

def new
@job_prospect=JobProspect.new
respond_to do |format|
format.html { render :action => "new" }
format.js
end
end
# def new
# @job_prospect=JobProspect.new
# respond_to do |format|
# format.html { render :action => "new" }
# format.js
# end
# end


def create
@job_prospects = JobProspect.where(:user_id => current_user.id)
@job_prospect = JobProspect.new( :company => params[:job_prospect][:company],
:position => params[:job_prospect][:position],
:user => current_user)
respond_to do |format|
if @job_prospect.save
format.html{redirect_to job_prospects_url}
format.js
else
format.html{ render :action => "create"}
format.js
end
end
@job_prospect.save ? respond_with(@job_prospect) : respond_with(@job_prospect, :status => unprocessable_entity)
end

def edit
@job_prospect = JobProspect.find(params[:id])
respond_to { |format| format.js }
end
# def edit
# @job_prospect = JobProspect.find(params[:id])
# respond_to { |format| format.js }
# end

def update
@job_prospect = JobProspect.find(params[:id])

respond_to do |format|
if @job_prospect.update_attributes(params[:job_prospect])
format.html{redirect_to job_prospects_url}
format.js
else
format.html{ render :action => "edit"}
format.js
end
end
@job_prospect.update_attributes(params[:job_prospect]) ? respond_with(@job_prospect) : respond_with(@job_prospect, :status => unprocessable_entity)
end

def show
@job_prospect = JobProspect.find_by_id_and_user_id(params[:id], current_user.id)
if @job_prospect
@events = Event.where(:job_prospect_id => @job_prospect.id).order("conversation_date").limit(5)
respond_with(@job_prospect, @events)
else
redirect_unauthorized_user
end
end

def destroy
@job_prospect = JobProspect.find(params[:id])
@job_prospect.destroy
respond_to do |format|
format.html{redirect_to job_prospects_url}
format.js
end
respond_with(@job_prospect.destroy)
end

end
Expand Down

0 comments on commit 100f5f5

Please sign in to comment.