我在我的 Rails 3.2 应用程序中使用Devise,我希望能够在 Google Analytics 中添加跟踪新注册作为转换。如果可能的话,我希望将新用户定向到他们现在被重定向到的同一页面(即,可能是重定向到当前页面的直通视图,用户在创建后被重定向到)。
有人可以帮我找出使用设计的最佳方法吗?
# users/registrations_controller.rb
# POST /resource
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_up(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
respond_with resource
end
end
def after_sign_up_path_for(resource)
after_sign_in_path_for(resource)
end