Skip to content

Instantly share code, notes, and snippets.

@fanktom
Created September 21, 2012 20:15
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/3763651 to your computer and use it in GitHub Desktop.
Save fanktom/3763651 to your computer and use it in GitHub Desktop.
Scaled Rails Controller
class TracksController < ApplicationController
# GET /tracks
def index
@tracks = Track.all
Scales.push :html => render("index"), :to => "/tracks"
end
# GET /tracks/1
def show
@track = Track.find(params[:id])
Scales.push :html => render("show"), :to => "/tracks/#{@track.id}"
end
# GET /tracks/new
def new
@track = Track.new
Scales.push :html => render("new"), :to => "/tracks/new"
end
# GET /tracks/1/edit
def edit
@track = Track.find(params[:id])
Scales.push :html => render("edit"), :to => "/tracks/#{@track.id}/edit"
end
# POST /tracks
def create
@track = Track.new(params[:track])
if @track.save
Scales.update "/tracks/#{@track.id}", "/tracks/#{@track.id}/edit", "/tracks", :format => :html
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])
Scales.update "/tracks/#{@track.id}", "/tracks/#{@track.id}/edit", "/tracks", :format => :html
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
Scales.destroy "/tracks/#{@track.id}", "/tracks/#{@track.id}/edit"
Scales.update "/tracks", :format => :html
redirect_to tracks_url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment