Ruby on rails server crashing when adding a new ac

2019-09-26 02:30发布

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.

This is the error I am getting on the server:

It would be great if someone could help me out!

EDIT

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

1条回答
三岁会撩人
2楼-- · 2019-09-26 03:21

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:

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.

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.

查看更多
登录 后发表回答