Sha256: 24eaca45fdd9eb18c6c19f77e763fcdcbc493ac49d88d38a9db1d3950cfd7f2a
Contents?: true
Size: 802 Bytes
Versions: 4
Compression:
Stored size: 802 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' #Require all models Dir[File.dirname(__FILE__) + "/models/*.rb"].each {|file| require file } 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/active_record/server.rb |
nyny-1.0.2 | examples/active_record/server.rb |
nyny-1.0.1 | examples/active_record/server.rb |
nyny-1.0.0 | examples/active_record/server.rb |