Rails / Haml: How to create a post form?

I'm trying to make a simple form, but it's working not so fine. This is my current form code:

%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" }

I am getting this url when trying to send data via form: 10.0.0.2:3000/activation. I know that I can make route tool#activation to activation, but it's a wrong way, I want to sent post query to 10.0.0.2:3000/tool/activation, but :action => 'tool/activation' also is a bad way as far as I understand.

Can you give me advice ?

Answers


You should use the rails helper tags.

= form_tag tool_activation_path, :method => :post do
    # The table
        # The row
            # The data
                = text_field_tag "accountName", ""
                = submit_tag "Submit"

See more here: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html

Also, you should try to avoid unnecessary tables to style your layout. Instead, look to using CSS.


Need Your Help

VSTS Rest API Get WorkItems By Field Value

azure-devops azure-devops-rest-api

Is there a way to retrieve a list of work items filtered by some field value?