Haml 表单未在 Sinatra 应用程序中提交
由于我已经在一个简单的 sinatra 应用程序中从 erb 转换为 haml,因此我在提交表单时遇到了问题。
new.haml
%form{ :action => "/new", :method => "post"}
%fieldset
%ol
%li
%label{:for => "username"} Name:
%input{:type => "text", :username => "name", :class => "text"}
%input{:type => "submit", :value => "Send", :class => "button"}
在我的 app.rb
get '/new' do
haml :new
end
post '/new' do
radcheck = Radcheck.new(:username => params[:username])
if radcheck.save
redirect '/'
else
"Hello World"
end
end
每次我收到 Hello World 语句时都会出现。我的日志没有显示任何有趣的内容。
有什么想法吗?与 erb 一起工作得很好?
I'm having problems submitting my form now that I've converted from erb to haml in a simple sinatra app.
new.haml
%form{ :action => "/new", :method => "post"}
%fieldset
%ol
%li
%label{:for => "username"} Name:
%input{:type => "text", :username => "name", :class => "text"}
%input{:type => "submit", :value => "Send", :class => "button"}
In my app.rb
get '/new' do
haml :new
end
post '/new' do
radcheck = Radcheck.new(:username => params[:username])
if radcheck.save
redirect '/'
else
"Hello World"
end
end
each time I get the Hello World statement appear. My logs show nothing interesting.
Any ideas? Worked just fine with erb??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我测试过的
和 new.haml
并且它按预期工作。因此,由于某种原因 radcheck.save 返回 false,但这与 haml 无关。 (但请注意,我已使用
:name => "username"
更正了输入)This is what I've tested
and new.haml
And it works as expected. So for some reason
radcheck.save
is returning false, but that has nothing to do with haml. (But notice that I have corrected input with:name => "username"
)