0

嗨,我是 ruby​​ on rails 的新手。我正在开发小型应用程序。当我尝试登录到我的应用程序时,它给了我错误ActionView::Template::Error ({}:Hash 的未定义方法 `login'):

我的登录表格看起来像

<%= form_for("user", :url => user_session_path, :html => { :id => "signinForm", :class => "regForms round", :style => "padding:0px 20px 20px;" }) do |f| %>
            <div class="signinupformDiv">
                <%= f.text_field :login, :class => "signupin-field-uname signupin-field last", :placeholder => "" %> // error occurred for this line as undefined method log in
                <%= f.label :login, :class => "signupin-label" %>
            </div>
            <div class="signinupformDiv">
                <%= f.password_field :password, :class => "signupin-field-pwd signupin-field last", :placeholder => "" %> //Error occurred at this line as undefined method password..    
                <%= f.label :password, :class => "signupin-label" %>
            </div>
            <div class="signupin-bl" style="width:240px;margin:0px auto 10px;"><span id="signinbutton-span" style="min-width:81px;text-align:center; margin-right:20px;"><%= f.submit 'Sign In', :id => "signInButton", :class => "regFormButton" %></span><%= link_to "Forgot your password?", new_password_path('user') %></div>
<% end %>

有什么办法可以处理这个错误。我是否做错了什么?

需要帮助...谢谢...

4

1 回答 1

0

检查您的控制器是否有@user. 它应该设置正确的值,似乎它被设置为一个空哈希({}),这就是你得到那个错误的原因。

我不知道你是如何设置它的,但你可能可以这样做:

@user = User.new
于 2012-10-15T12:29:14.160 回答