为开源项目 Kandan 添加新帐户时,Ruby on rails 服务器崩溃 [英] Ruby on rails server crashing when adding a new account for open source project Kandan
问题描述
我可以使用 ruby on rails 成功地让我的本地服务器与开源项目 kandan 一起运行,但是一旦我单击创建新帐户"按钮,它就会按预期将我重定向到主页,但服务器立即崩溃.
I can successfully get my local server running with open source project kandan using ruby on rails, however as soon as I click the "create new account" button, it redirects me to the home page as expected but then the server crashes immediately.
如果有人能帮助我就好了!
It would be great if someone could help me out!
编辑
Here is the routes file
Kandan::Application.routes.draw do
devise_for :users, :controllers => {
:sessions => "sessions"
}
devise_scope :user do
authenticated :user do
root :to => "main#index"
get '/search' => "main#search"
resources :channels do
resources :activities
resources :attachments
end
resources :users, :only => [:index, :show]
get "/active_users" => "apis#active_users"
get "/me" => "apis#me"
get "/users/edit" =>"main#users_edit"
namespace :admin do
root :to => "admin#index"
post "/update", :to => "admin#update", :as => "update"
post "/update_user", :to => "admin#update_user", :as => "update_user"
post "/toggle_admin", :to => "admin#toggle_admin"
end
end
unauthenticated do
root to: "sessions#new"
end
end
# Pages Controller
get "/approval", :to => "pages#approval"
get "/suspended", :to => "pages#suspended"
get "/about", :to =>"pages#about"
end
推荐答案
这看起来像是控制器中的重定向问题.看这里:
It looks like a problem with a redirect in your controller. Look here:
Started GET "/channels/undefined/attachments" for 127.0.0.1 at 2015-08-08 02:17:58 +1000
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Processing by AttachmentsController#index as JSON
Parameters: {"channel_id"=>"undefined"}
Channel Load (0.1ms) SELECT "channels".* FROM "channels" WHERE "channels"."id" = ? LIMIT 1 [["id", "undefined"]]
Completed 404 Not Found in 1.2ms
ActiveRecord::RecordNotFound - Couldn't find Channel with id=undefined:
此获取是在您向用户发布后很久.它们之间有几个 GET 请求,但是您可以看到这个 GET 请求正在发送一个未定义"的 id 作为参数.您用来传递 ID 的任何变量都没有正确初始化.
This get is long after your POST to users. There are several GET requests between them, but you can see that this GET request is sending an 'undefined' id as a parameter. Whatever variable you are using to pass the ID is not properly initialized.
如果您正在进行基于浏览器的测试(而不是 TDD 等),那么我建议您安装 Better Errors gem.当一个错误被抛出时,它会通过你的浏览器一个可用的 shell 和一个所有局部变量的列表.如果您希望应用程序在某个点停止,您甚至可以引发异常(raise "STOP HERE"
).它是一个拐杖,最好使用几个有据可查的 TDD 方法中的一个,但它是一个非常漂亮和花哨的拐杖.
If you are doing browser-based testing (rather than TDD, et. al.), then I recommend installing the Better Errors gem. When an error is thrown it passes your browser a usable shell and a list of all the local variables. You can even raise an exception (raise "STOP HERE"
) if you want the application to stop at a certain point. It is a crutch, and it is better to use one of several very well documented TDD approaches, but it is a very nice and fancy crutch.
这篇关于为开源项目 Kandan 添加新帐户时,Ruby on rails 服务器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!