简体   繁体   中英

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. How is that done? I searched for days!

......

Is this erb? if so, you should use form_for and simply give it the sessions object. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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