意外的tIDENTIFIER

时间:2014-03-06 05:09:18

标签: ruby-on-rails ruby

我正在尝试为我的网站制作一个简单的用户身份验证系统,但我不断收到此错误消息:

  

C:/ Users / Chris / Documents / DePaul / IT 231 / chocolate / app / controllers / simplelogin_controller.rb:8:语法错误,意外的tIDENTIFIER,期待keyword_then或';'或'\ n'... name(name_out)redirect_to maintenance_chkmaintenance_p ...... ... C:/ Users / Chris / Documents / DePaul / IT 231 / chocolate / app / controllers / simplelogin_controller.rb:11:语法错误,意外的keyword_end,期待$ end end end end ^

这是我的控制器:

Class SimpleloginController < ApplicationController  
  def namein    

  end

  def transmain  
    @familyname_out = params[:family_name_in] #textbox name from the input file 
    name_out  = params[:family_name_in]   
    if found = Family.find_by_name(name_out)   
      redirect_to maintenance_chkmaintenance_path :notice => "Logged in successfully" 
    else  
      redirect_to simplelogin_namein_path :notice => "Invalid login. Try again" 
    end    
  end 
end

有什么想法吗?

3 个答案:

答案 0 :(得分:2)

在您的代码中,重定向的语法是

redirect_to YOUR_PATH :notice => "YOUR NOTICE"

此处:notice

之前缺少逗号','

所以,试试这个。

redirect_to YOUR_PATH, :notice => "YOUR NOTICE"

答案 1 :(得分:2)

Class SimpleloginController < ApplicationController  
  def namein    

  end

  def transmain  
    @familyname_out = params[:family_name_in] #textbox name from the input file 
    name_out  = params[:family_name_in]   
    if found = Family.find_by_name(name_out)   
      redirect_to maintenance_chkmaintenance_path, :notice => "Logged in successfully" 
    else  
      redirect_to simplelogin_namein_path, :notice => "Invalid login. Try again" 
    end    
  end 
end

redirect_to maintenance_chkmaintenance_path, :notice => "Logged in successfully"

中的问题

您没有给出(逗号)所以发生语法错误

答案 2 :(得分:1)

您在redirect_to来电

中缺少逗号
redirect_to maintenance_chkmaintenance_path :notice => "Logged in successfully" 
...
redirect_to simplelogin_namein_path :notice => "Invalid login. Try again"

应该是

redirect_to maintenance_chkmaintenance_path, :notice => "Logged in successfully" 
...
redirect_to simplelogin_namein_path, :notice => "Invalid login. Try again"