app/controllers/projects_controller.rb
class ProjectsController < ApplicationController
def index
@projects = Project.all
end
def new
@project = Project.new
end
def create
@project = Project.new(params[:project])
if @project.save
redirect_to projects_path, :notice => "Successfully created project."
else
render :action => 'new'
end
end
def edit
@project = Project.find(params[:id])
end
def update
@project = Project.find(params[:id])
if @project.update_attributes(params[:project])
redirect_to projects_path, :notice => "Successfully updated project."
else
render :action => 'edit'
end
end
def destroy
@project = Project.find(params[:id])
@project.destroy
redirect_to projects_path, :notice => "Successfully destroyed project."
end
end