2014-03-06 81 views
0

我試圖做一個簡單的用戶認證系統爲我的網站,但我不斷收到此錯誤信息:意外tIDENTIFIER

C:/用戶/克里斯/文檔/德保羅/ IT 231 /巧克力/應用/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,預計年底$結束結束結束^

這裏是我的控制器:

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 

任何想法?

回答

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"

你不給(逗號),所以語法錯誤在你redirect_to通話時發生

+0

你的救星謝謝你 – user3281827

2

在你的代碼重定向到語法

redirect_to YOUR_PATH :notice => "YOUR NOTICE" 

這裏一個逗號「」丟失之前:notice

所以,儘量與此有關。

redirect_to YOUR_PATH, :notice => "YOUR NOTICE" 
+2

不只是解決問題,告訴他問題是什麼。 – sevenseacat

1

你缺少一個逗號

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

應be

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