1
我正在研究一個應用程序,該應用程序有幾個需要用戶登錄才能訪問的區域。 (我正在使用設計邏輯)。在編輯配置文件和會話時出現錯誤
我目前在我的應用程序控制器中使用以下內容來記住目標網址(用戶點擊(需要身份驗證)的鏈接),以便在用戶身份驗證後(按照How to direct user to a specific page after logging in with Devise and Rails)進行登錄。
class ApplicationController < ActionController::Base
helper :content
protect_from_forgery
def after_sign_in_path_for(user)
origin_path = session[:origin_path]
default_redirect_path ="/"
clear_origin_path
if origin_path.present?
origin_path
else
params[:target].presence || default_redirect_path
end
end
private
def authenticate_user!
store_origin_path
super
end
def store_session
store_origin_path
end
def store_origin_path
session[:origin_path] = request.fullpath
end
def clear_origin_path
session[:origin_path] = nil
end
end
這一切的偉大工程,但我剛纔注意到,當我嘗試訪問「/用戶/編輯」,我現在給出的錯誤:
ArgumentError in Devise::RegistrationsController#edit
wrong number of arguments (1 for 0)
Rails.root: /home/james/*******
Application Trace | Framework Trace | Full Trace
app/controllers/application_controller.rb:19:in `authenticate_user!'
Request
Parameters:
None
Show session dump
_csrf_token: "XmrTSQOQ3Z0XTSn14LAX8LtMNVOwM4q3bQ+UhxjvgGM="
session_id: "2caaccc944774f2a7ac6f440c2f442d9"
user_return_to: "/my_tendersave"
warden.user.user.key: ["User", [1], "$2a$10$foTK/Em72/E0rILIuUv7su"]
warden.user.user.session: {"last_request_at"=>2013-01-25 01:48:43 UTC}
Show env dump
GATEWAY_INTERFACE: "CGI/1.2"
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_CHARSET: "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
HTTP_ACCEPT_ENCODING: "gzip,deflate,sdch"
HTTP_ACCEPT_LANGUAGE: "en-GB,en-US;q=0.8,en;q=0.6"
REMOTE_ADDR: "127.0.0.1"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"
Response
Headers:
None
我能做些什麼,以確保這有用嗎?
我是否需要更改應用程序控制器?
或重寫其他一些設計方法。
在此先感謝您的幫助。
我生氣了,但終於奏效了!謝謝! – itziki