Skip to content

Instantly share code, notes, and snippets.

@leemcalilly
Created June 7, 2013 21:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemcalilly/7fca5f2c81c6cb4de6bc to your computer and use it in GitHub Desktop.
Save leemcalilly/7fca5f2c81c6cb4de6bc to your computer and use it in GitHub Desktop.
class WorksController < ApplicationController
# GET /works
def index
@works = Work.all
@uploader = Work.new.image
@uploader.success_action_redirect = new_work_url
respond_to do |format|
format.html # index.html.erb
end
end
# GET /works/1
def show
@work = Work.find(params[:id])
respond_to do |format|
format.html # show.html.erb
end
end
# GET /works/new
def new
@work = Work.new(key: params[:key])
respond_to do |format|
format.html # new.html.erb
end
end
# GET /works/1/edit
def edit
@work = Work.find(params[:id])
end
# POST /works
def create
@work = Work.new(params[:work])
respond_to do |format|
if @work.save
format.html { redirect_to @work, notice: 'Work was successfully created.' }
else
format.html { render action: "new" }
end
end
end
# PUT /works/1
def update
@work = Work.find(params[:id])
respond_to do |format|
if @work.update_attributes(params[:work])
format.html { redirect_to @work, notice: 'Work was successfully updated.' }
else
format.html { render action: "edit" }
end
end
end
# DELETE /works/1
def destroy
@work = Work.find(params[:id])
@work.destroy
respond_to do |format|
format.html { redirect_to works_url }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment