Created
September 21, 2012 20:15
-
-
Save fanktom/3763651 to your computer and use it in GitHub Desktop.
Scaled Rails Controller
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 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