Sha256: d9498368105e310c7af26b8ed9ae839a53b4fc7218d2bbd1b65e78e27f2428f0

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

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 = <<-EOTEXT
  Hello #{user['name']}!

  Copy and paste this URL into your browser to confirm your account!

  http://www.example.com/confirm
  This is the text part.
    EOTEXT
    html_body = <<-EOHTML
  Hello #{user['name']}!

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
email_spec-2.3.0 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-2.2.2 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-2.2.1 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-2.2.0 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-2.1.2 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-2.1.1 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-2.1.0 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-2.0.0 examples/sinatra_root/lib/example_sinatra_app.rb
email_spec-1.2.1 examples/sinatra_root/lib/example_sinatra_app.rb