Created
November 25, 2010 10:29
-
-
Save onlymejosh/715183 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
Routes | |
namespace :af do | |
resources :shows do | |
resources :presentations | |
end | |
resources :presentations do | |
resources :keynotes | |
resources :videos | |
end | |
resources :keynotes do | |
resources :slides | |
end | |
end | |
namespace :af do resources :videos end | |
namespace :af do resources :slides end | |
namespace :af do resources :topics end | |
namespace :af do resources :keynotes end | |
namespace :af do resources :shows end | |
Models | |
class Af::Presentation < ActiveRecord::Base | |
belongs_to :show | |
has_one :video, :dependent => :delete | |
has_one :keynote, :dependent => :delete | |
accepts_nested_attributes_for :video, :keynote | |
end | |
class Af::Keynote < ActiveRecord::Base | |
belongs_to :presentation | |
has_many :slides, :dependent => :destroy | |
has_attached_file :keynote | |
end | |
class Af::PresentationsController < ApplicationController | |
# GET /af/presentations | |
# GET /af/presentations.xml | |
def index | |
@af_presentations = Af::Presentation.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @af_presentations } | |
end | |
end | |
# GET /af/presentations/1 | |
# GET /af/presentations/1.xml | |
def show | |
@af_presentation = Af::Presentation.find(params[:id]) | |
respond_to do |format| | |
format.html # show.html.erb | |
format.xml { render :xml => @af_presentation } | |
end | |
end | |
# GET /af/presentations/new | |
# GET /af/presentations/new.xml | |
def new | |
@af_presentation = Af::Presentation.new | |
1.times { @af_presentation.keynote.build} | |
respond_to do |format| | |
format.html # new.html.erb | |
format.xml { render :xml => @af_presentation } | |
end | |
end | |
# GET /af/presentations/1/edit | |
def edit | |
@af_presentation = Af::Presentation.find(params[:id]) | |
end | |
# POST /af/presentations | |
# POST /af/presentations.xml | |
def create | |
@af_presentation = Af::Presentation.new(params[:af_presentation]) | |
respond_to do |format| | |
if @af_presentation.save | |
format.html { redirect_to(@af_presentation, :notice => 'Presentation was successfully created.') } | |
format.xml { render :xml => @af_presentation, :status => :created, :location => @af_presentation } | |
else | |
format.html { render :action => "new" } | |
format.xml { render :xml => @af_presentation.errors, :status => :unprocessable_entity } | |
end | |
end | |
end | |
# PUT /af/presentations/1 | |
# PUT /af/presentations/1.xml | |
def update | |
@af_presentation = Af::Presentation.find(params[:id]) | |
respond_to do |format| | |
if @af_presentation.update_attributes(params[:af_presentation]) | |
format.html { redirect_to(@af_presentation, :notice => 'Presentation was successfully updated.') } | |
format.xml { head :ok } | |
else | |
format.html { render :action => "edit" } | |
format.xml { render :xml => @af_presentation.errors, :status => :unprocessable_entity } | |
end | |
end | |
end | |
# DELETE /af/presentations/1 | |
# DELETE /af/presentations/1.xml | |
def destroy | |
@af_presentation = Af::Presentation.find(params[:id]) | |
@af_presentation.destroy | |
respond_to do |format| | |
format.html { redirect_to(af_presentations_url) } | |
format.xml { head :ok } | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment