Skip to content

Instantly share code, notes, and snippets.

@jellybob
Created July 16, 2010 10:46
Show Gist options
  • Save jellybob/478222 to your computer and use it in GitHub Desktop.
Save jellybob/478222 to your computer and use it in GitHub Desktop.
A snippet of the Sinatra app I'm using to interact with chef databags
# ...snip...
get '/users' do
@users = User.all
erb :users
end
get '/users/new' do
@user = User.new
erb :user_form
end
post '/users' do
@user = User.new(params[:user])
if @user.valid?
@user.save
flash[:info] = "The user account for #{@user.username} has been created, and will become active over the next 15-20 minutes."
redirect "/users"
else
@errors = @user.errors.full_messages
erb :user_form
end
end
# ...snip...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment