alt*_*pub 10 forms haml ruby-on-rails
我正在尝试制作一个简单的表格,但它的工作并不那么好.这是我目前的表单代码:
%form{ :controller => 'tool', :action => 'activation', :method => 'post' }
%table{ :border => 0, :width => "100%", :height => "100%" }
%tr{ :align => "center", :valign => "center" }
%td
%input{ :type => "text", :name => "accountName" }
%input{ :type => "submit", :name => "submit", :value => "login" }
Run Code Online (Sandbox Code Playgroud)
我在尝试通过表单发送数据时收到此URL : 10.0.0.2:3000/activation. 我知道我可以tool#activation启动激活路由,但这是一种错误的方式,我想发送帖子查询10.0.0.2:3000/tool/activation,但:action => 'tool/activation'据我所知,这也是一种不好的方式.
你能给我一些建议吗?
MrD*_*anA 18
您应该使用rails helper标签.
= form_tag tool_activation_path, :method => :post do
# The table
# The row
# The data
= text_field_tag "accountName", ""
= submit_tag "Submit"
Run Code Online (Sandbox Code Playgroud)
在此处查看更多信息:http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html
此外,您应该尝试避免不必要的表来设置您的布局样式.相反,期待使用CSS.