Skip to content

Instantly share code, notes, and snippets.

@fanktom
Created September 21, 2012 20:13
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 fanktom/3763637 to your computer and use it in GitHub Desktop.
Save fanktom/3763637 to your computer and use it in GitHub Desktop.
Normal Rails Controller
class TracksController < ApplicationController
# GET /tracks
def index
@tracks = Track.all
render "index"
end
# GET /tracks/1
def show
@track = Track.find(params[:id])
render "show"
end
# GET /tracks/new
def new
@track = Track.new
render "new"
end
# GET /tracks/1/edit
def edit
@track = Track.find(params[:id])
render "edit"
end
# POST /tracks
def create
@track = Track.new(params[:track])
if @track.save
redirect_to @track, notice: 'Track was successfully created.'
else
render action: "new"
end
end
# PUT /tracks/1
def update
@track = Track.find(params[:id])
if @track.update_attributes(params[:track])
redirect_to @track, notice: 'Track was successfully updated.'
else
render action: "edit"
end
end
# DELETE /tracks/1
def destroy
@track = Track.find(params[:id])
@track.destroy
redirect_to tracks_url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment