Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created September 12, 2008 07:08
Show Gist options
  • Save joevandyk/10396 to your computer and use it in GitHub Desktop.
Save joevandyk/10396 to your computer and use it in GitHub Desktop.
class Groups < Application
# provides :xml, :yaml, :js
def index
@groups = Group.all
display @groups
end
def show
@group = Group.get(params[:id])
raise NotFound unless @group
display @group
end
def new
only_provides :html
@group = Group.new
render
end
def edit
only_provides :html
@group = Group.get(params[:id])
raise NotFound unless @group
render
end
def create
@group = Group.new(params[:group])
if @group.save
redirect url(:group, @group)
else
render :new
end
end
def update
@group = Group.get(params[:id])
raise NotFound unless @group
if @group.update_attributes(params[:group]) || !@group.dirty?
redirect url(:group, @group)
else
raise BadRequest
end
end
def destroy
@group = Group.get(params[:id])
raise NotFound unless @group
if @group.destroy
redirect url(:group)
else
raise BadRequest
end
end
end # Groups
%h1 Create A New Group
= error_messages_for :group
= form_for(@group, :action => url(:groups) ) do |f|
= partial :form
%p
= submit "Create"
= link_to 'Back', url(:groups)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment