secret
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.