Sha256: f265ef5988fe47f15111bdf3f902afbfc4638a2d4cdf0c34b034a132cca1c969

Contents?: true

Size: 709 Bytes

Versions: 4

Compression:

Stored size: 709 Bytes

Contents

#!ruby -I ../../lib -I lib

ENV['RACK_ENV'] ||= 'development'

require 'rubygems'
require 'bundler'
Bundler.setup(:default, ENV['RACK_ENV'].to_sym)

require 'nyny'
require_relative 'database'

TEMPLATE = DATA.read.freeze

class App < NYNY::App
  get '/' do
    shouts = Shout.all.reverse
    ERB.new(TEMPLATE).result(binding)
  end

  post '/shouts' do
    Shout.create :body => params[:body]
    redirect_to '/'
  end
end

App.run! 9000

__END__
<html>
<body>
  <form action="/shouts" method="post">
    <input type="text" name="body"></input>
    <input type="submit" value="SHOUT"></input>
  </form>
  <ul>
    <% shouts.each do |shout| %>
      <li><%= shout.body %>
    <% end %>
  </ul>
</body>
</html>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nyny-2.0.0 examples/data_mapper/server.rb
nyny-1.0.2 examples/data_mapper/server.rb
nyny-1.0.1 examples/data_mapper/server.rb
nyny-1.0.0 examples/data_mapper/server.rb