Здравствуй, Хабр!
Не могу понять в чем дело. Помогите, пожалуйста. Выводит ошибку
First argument in form cannot contain nil or be empty. Ошибка возникает при авторизации юзера
Логи сервера
Started POST "/users/log_in" for 127.0.0.1 at 2014-04-25 17:38:06 +0400
Processing by UsersController#log_in as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"BA7a1ItyjvAJERAdL70Agj3h1j4Y7RvbYHMKe7BvfcI=", "user"=>{"login"=>"mrZaur", "password"=>"[FILTERED]"}, "commit"=>"auth"}
User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'mrZaur' LIMIT 1
Rendered users/auth.html.slim (1.7ms)
Completed 500 Internal Server Error in 7ms
ActionView::Template::Error (First argument in form cannot contain nil or be empty):
1: = form_for @user, url: {action: "log_in"} do |f|
2: table
3: tr
4: td = f.label :login
app/views/users/auth.html.slim:1:in `_app_views_users_auth_html_slim___1368928838574431298_11313500'
app/controllers/users_controller.rb:29:in `log_in'
Rendered /home/zaur/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.4/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /home/zaur/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.7ms)
Rendered /home/zaur/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.4/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (10.5ms)
Сама форма ввода:
= form_for @user, url: {action: "log_in"} do |f| #сюда указывает как на ошибку
table
tr
td = f.label :login
td = f.text_field :login
tr
td = f.label :password
td = f.password_field :password
tr
td = f.submit :auth
контроллер:
def log_in
user = User.find_by login: params[:user][:login]
if user && user.authenticate(params[:user][:password])
session_start
redirect_to_gallery
else
render "auth"
end
end
private
def session_start
session[:user_id] = @user.id
end
def redirect_to_gallery
redirect_to :controller => 'gallery', :action => 'index'
end