导轨栏中的登录表单

时间:2012-07-10 09:29:41

标签: ruby-on-rails ruby-on-rails-3 forms

我为导航栏创建了此表单:

<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>

表单位于导航栏上,我必须告诉它进入sessions controller并使用create操作。怎么做的?我搜索了几天!

...

2 个答案:

答案 0 :(得分:1)

这是erb吗?如果是这样,你应该使用form_for并简单地给它session对象。请参阅here

答案 1 :(得分:0)

你可以这样做:

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

如此处所述:Rails Guides: Multiple Hashes in form helpers