Ruby on rails 4 错误:没有将符号隐式转换为整数

Ruby on rails 4 错误:没有将符号隐式转换为整数,ruby-on-rails-4,Ruby On Rails 4,我是RubyonRails新手,我想为每个登录用户创建一个会话。 但我得到了那个错误。 在我的控制器中,我有: class SessionsController < ApplicationController def new end def create user =User.find_by pseudo :params[:pseudo] if user session[:user_id]=user.id flash[:notice]= "you are signed in! "

我是RubyonRails新手,我想为每个登录用户创建一个会话。 但我得到了那个错误。 在我的控制器中,我有:

class SessionsController < ApplicationController
def new
end

def create
user =User.find_by pseudo :params[:pseudo]
if user
  session[:user_id]=user.id
  flash[:notice]= "you are signed in! "
  redirect root_url
else
  flash.now[:alert]= "wrong password/pseudo"
  render 'new'
end
end

def destroy
session[:user_id]=nil
flash[:notice]='You are now signed out'
redirect root_url
end
end
class sessioncontroller
在my new.html.erb中:

<h1>Sessions#new</h1>
<%= form_tag sessions_path do  %>
<div>
<%=label_tag 'pseudo', 'pseudo' %>
<%= text_field_tag 'pseudo' %>
</div>
<div>
  <%= label_tag 'password', 'password' %>
  <%= password_field_tag 'password' %>
</div>
  <%= submit_tag 'log in' %>


<% end %>
会话#新增
在我的索引中,我有:

<h1>Users#index</h1>
<% if current_user.present? %>
Welcome <%= current_user.pseudo %> | <%= link_to 'Sign out' , logout_path %>

<% else %>
<%= link_to 'Register', new_user_url %><br/>
<%= link_to 'SignIn', login_path %>
<% end %>
用户#索引
欢迎

在应用程序_controller.rb中:

 class ApplicationController < ActionController::Base
 # Prevent CSRF attacks by raising an exception.
 # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  helper_method :current_user
  private
  def current_user
  User.find_by id: session[:user_id] if session[:user_id]
  end
  end
class ApplicationController

这个错误与“user=user.find_by pseudo:params[:pseudo]”有关,我不明白为什么
create
action:
user=user.find_by pseudo:params[:pseudo]
是的,谢谢,但我还有一个问题,我现在遇到了这个错误“没有路由匹配[GET]”“我知道我的路由是这样的:Helper HTTP动词路径控制器#Action Path/Url sessions#new#u Path GET/sessions/new(:format)sessions#new root#u Path GET/users#index users#Path POST/users(:format)users#创建新的#用户(Path GET/users/new format)users#new会话#创建登录#路径获取/登录(:格式)会话#新注销#路径获取/注销(:格式)会话#销毁将新方法
def index end
添加到会话控制器并阅读有关路由的更多信息:谢谢!我为这些愚蠢的问题感到抱歉,我将阅读更多关于路由的内容!