我对这三个东西都很陌生,现在我正在尝试为一个网站编写一个简单的联系表格。下面是我想出来的代码,但我知道它存在一些基本问题(因为我对sinatra不熟悉)。如果有人能帮我让它正常工作,我将不胜感激。我似乎无法找到这类东西的文档。
来自联系页面的Haml代码:
%form{:name => "email", :id => "email", :action => "/contact", :method => "post", :enctype => "text/plain"}
%fieldset
%ol
%li
%label{:for => "message[name]"} Name:
%input{:type => "text", :name => "message[name]", :class => "text"}
%li
%label{:for => "message[mail]"} Mail:
%input{:type => "text", :name => "message[mail]", :class => "text"}
%li
%label{:for => "message[body]"} Message:
%textarea{:name => "message[body]"}
%input{:type => "submit", :value => "Send", :class => "button"}
以下是我的sinatra的app.rb代码:
require 'rubygems'
require 'sinatra'
require 'haml'
require 'pony'
get '/' do
haml :index
end
get '/contact' do
haml :contact
end
post '/contact' do
name = #{params[:name]}
mail = #{params[:mail]}
body = #{params[:body]}
Pony.mail(:to => '*emailaddress*', :from => mail, :subject => 'art inquiry from' + name, :body => body)
end