-
-
Save leemcalilly/7fca5f2c81c6cb4de6bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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