Sha256: dd4646e6dc0bad775d594653f039d984687d4d386561ee4accf53a600942f491

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

require 'sinatra/base'
require 'pony'

class ExampleSinatraApp < Sinatra::Base
  get '/' do
    <<-EOHTML
  <form method="post" action="/signup">
      <label for="Name">Name</label>
      <input type="text" id="Name" name="user[name]">
      <label for="Email">Email</label>
      <input type="text" id="Email" name="user[email]">
      <input type="submit" value="Sign up">
  </form>
    EOHTML
  end

  post '/signup' do
    user = params[:user]
    body = <<-EOHTML
  Hello #{user['name']}!

  <a href="http://www.example.com/confirm">Click here to confirm your account!</a>
    EOHTML
    Pony.mail(:from => 'admin@example.com',
              :to => user['email'],
              :subject => 'Account confirmation',
              :body => body
             )
             'Thanks!  Go check your email!'
  end

  get '/confirm' do
    'Confirm your new account!'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
email_spec-1.0.1 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-1.2.0 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-1.1.1 examples/sinatra_root/lib/example_sinatra_app.rb