我收到此错误:
NoMethodError in Sessions#login
Showing c:/Documents and Settings/OverDuka/Desktop/controle/controle/app/views/sessions/login.html.erb where line #5 raised:
undefined method `model_name' for NilClass:Class
Extracted source (around line #5):
2: <% if flash[:note]%>
3: <%= flash[:note] %>
4: <%end%>
5: <%=form_for @user do |f| %>
6: Nome: <%= f.text_field :name %>
7: Senha: <%= f.password_field :password %>
8: <%= f.submit %>
我做了一个简单的登录系统,但这不起作用,我的控制器是:
class SessionsController < ApplicationController
def login
@user = User.where(params[:name],params[:password]).first
if @user
session[:user_id] = @user.id
flash[:note] = 'Voce esta logado.'
redirect_to finances_url
else
flash[:note] = 'Falha no login.'
end
end
def destroy
end
end
我的路线是
match 'login' => 'sessions#login', :as => :login
resources :finances