routing - Do not post a form in a Rails root route -
i have controller 1 method:
index_controller.rb def index # code end the form:
index.html.erb <%= form_tag :class => "form-inline signup" %> <div class="form-group"> <%= text_field_tag :url, nil, :class => "form-control", :placeholder => "url tópico" %> </div> <%= submit_tag "enviar", method: :post, :class => 'btn btn-theme' %> <% end %> and simple root route:
root 'index#index' post '/', to: 'index#index' the problem when load root page, form posted automatically, when preferable post on button call.
what missing here?
you should move code post out action can handle that.
post '/', :to => "index#submit" then can define submit action within indexcontroller handle form, , index action won't run form code anymore.
Comments
Post a Comment