我是所有三個新手,我試圖寫一個簡單的網站聯繫表格。我提出的代碼如下,但我知道它有一些基本問題(由於我對sinatra沒有經驗)。任何幫助獲得這項工作將不勝感激,我似乎無法弄清楚/找到這種事情的文件。從聯繫人頁面在紅寶石,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
哪裏的了'GET'和你得到了什麼錯誤? 另外,消息[郵件]的命名是什麼?爲什麼不只是「郵件」? – 2010-01-14 23:24:02