Skip to content

Instantly share code, notes, and snippets.

@buk
Created April 14, 2011 17:21
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 buk/919974 to your computer and use it in GitHub Desktop.
Save buk/919974 to your computer and use it in GitHub Desktop.
class ReportsController < ApplicationController
#before_filter :find_technician
def index
@reports = @technician.reports
end
def show
@report = @technician.report.find(params[:id])
end
def new
@report = @technician.report.new
end
def create
@technician.report.create(params[:report])
@report = Report.new(params[:report])
if @report.save
redirect_to @report, :notice => "Successfully created report."
else
render :action => 'new'
end
end
def edit
@report = @technician.report.find(params[:id])
end
def update
@report = @technician.report.find(params[:id])
if @report.update_attributes(params[:report])
redirect_to @report, :notice => "Successfully updated report."
else
render :action => 'edit'
end
end
def destroy
@report = @technician.report.find(params[:id])
@report.destroy
redirect_to reports_url, :notice => "Successfully destroyed report."
end
private
def find_technician
@technician = Technician.find(params[:technician_id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment