Skip to content

Instantly share code, notes, and snippets.

@maceto
Created August 24, 2011 19:19
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 maceto/1168929 to your computer and use it in GitHub Desktop.
Save maceto/1168929 to your computer and use it in GitHub Desktop.
Cuba.define do
@message=""
# only GET requests
on get do
# /
on "" do
@players = Player.all(:order => [ :name.desc ])
res.write render('views/index.haml')
end
end
# only POST requests
on post do
on "players" do
on param("player") do |player_attributes|
player = Player.new(player_attributes)
if player.save
@message = "La inscripcion se realizo con exito !!!"
res.redirect "/"
else
player.errors.each do |e|
@message += e.to_s
end
res.redirect "/"
puts @message
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment