Skip to content

Instantly share code, notes, and snippets.

@tejo
Created February 20, 2015 14:17
Show Gist options
  • Save tejo/ab6f2aae543d9be74564 to your computer and use it in GitHub Desktop.
Save tejo/ab6f2aae543d9be74564 to your computer and use it in GitHub Desktop.
<form action="/" method="POST">
<h3> Messaggio </h3>
<input type="text" name="message" value=<%= params[:message] %>>
<h3> Email </h3>
<input type="text" name="email" value=<%= params[:email] %>>
<input type="submit" value="Inserisci ">
</form>
<% @messages.each do |m| %>
<p><%= m[:email] %> </p>
<p><%= m[:message] %> </p>
<% end %>
require 'sinatra'
require 'pry'
class Form
attr_reader :messages
def initialize
@messages = []
end
end
f = Form.new
get "/" do
@messages = f.messages
erb :index
end
post "/" do
@messages = f.messages
@messages << {email:params[:email] , message: params[:message]}
erb :index
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment