Skip to content

Instantly share code, notes, and snippets.

@joshbuddy
Forked from dariocravero/gist:563016
Created September 2, 2010 21:53
Show Gist options
  • Save joshbuddy/563018 to your computer and use it in GitHub Desktop.
Save joshbuddy/563018 to your computer and use it in GitHub Desktop.
Wakupdude.controllers :dudes do
set :haml, {:format => :html5 }
# get :index do
# render "dudes/index"
# end
get :all, "/" do
@dudes = Dude.all()
render "dudes/list"
end
get :read, "/:id" do
@dude = Dude.find_by_id(params[:id])
render "dudes/read"
end
get :create, "/create" do
render "dudes/create"
end
post :create, "/" do
params.inspect
@dude = Dude.new(params[:dude])
if @dude.save
# flash[:notice] = 'The dude was successfully created.'
redirect url(:dudes, :read, :id => @dude.id)
else
redirect url(:dudes, :all)
end
end
delete :delete, "/:id" do
@dude = Dude.find_by_id(params[:id])
@dude.destroy
redirect url(:dudes, :all)
end
post :update, "/post/:id" do
@dude = Dude.find_by_id(params[:id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment