简体   繁体   English

Rails导航栏上的登录表单

[英]login form on navigation bar in rails

I have created this form for my navigation bar: 我已经为导航栏创建了以下表单:

<form action="/sessions" method="post" class="well form-inline">  
<input id="user_email" name="user[email]" type="text" placeholder="Email">  
<input id="user_password" name="user[password]" type="password" placeholder="Password">  
<label class="checkbox">  
<input type="checkbox"> Remember me  
</label>  
<button name="commit" type="submit" class="btn">Sign in</button>  
</form>

The form is located on the navigation bar, and I have to tell it to go into the sessions controller and use the create action. 该表单位于导航栏上,我必须告诉它进入sessions controller并使用create动作。 How is that done? 怎么做? I searched for days! 我搜索了几天!

...... ......

Is this erb? 这是erb吗? if so, you should use form_for and simply give it the sessions object. 如果是这样,则应使用form_for并简单地为其指定session对象。 See here . 这里

You could do: 您可以这样做:

<% form_tag(:controller => "/search", :action => "create", :method => "post") do %>
    # The input fields and other fields
    # <%= input_tag(..params..) %> and so on
<% end %>

as mentioned here : Rails Guides: Multiple Hashes in form helpers 如此处所述: Rails指南:表单助手中的多个哈希

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM