Skip to content

Instantly share code, notes, and snippets.

@dariocravero
Created September 2, 2010 21:51
Show Gist options
  • Save dariocravero/563016 to your computer and use it in GitHub Desktop.
Save dariocravero/563016 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, :map => "/" do
@dudes = Dude.all()
render "dudes/list"
end
get :read, :map => "/", :with => :id do
@dude = Dude.find_by_id(params[:id])
render "dudes/read"
end
get :create, :map => "/create" do
render "dudes/create"
end
post :create, :map => "/" 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, :map => "/", :with => :id do
@dude = Dude.find_by_id(params[:id])
@dude.destroy
redirect url(:dudes, :all)
end
post :update, :with => :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