Skip to content

Instantly share code, notes, and snippets.

Created July 9, 2012 20:46
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 anonymous/3078792 to your computer and use it in GitHub Desktop.
Save anonymous/3078792 to your computer and use it in GitHub Desktop.
class EthosController < ApplicationController
before_filter :require_user, :only => [:create, :new, :edit, :update]
def index
@ethos = Etho.all
@etho = Etho.new
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @ethos }
end
end
def new
@etho = current_user.etho
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @etho }
end
end
def edit
@etho = Etho.find(params[:etho])
end
def create
@etho = Etho.new(params[:etho])
@etho.user = current_user
respond_to do |format|
if @etho.save
format.html { redirect_to(:back, :notice => 'Ethos was successfully created.') }
format.xml { render :xml => @etho, :status => :created, :location => @etho }
else
format.html { render :action => "new" }
format.xml { render :xml => @etho.errors, :status => :unprocessable_entity }
end
end
end
def show
end
def update
@etho = Etho.find(params[:id])
respond_to do |format|
if @etho.update_attributes(params[:etho])
format.html { redirect_to(:back, :notice => 'Ethos was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @etho.errors, :status => :unprocessable_entity }
end
end
end
def destroy
@etho = Etho.find(params[:id])
@etho.destroy
respond_to do |format|
format.html { redirect_to(ethos_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