Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`default_controller_and_action': missing :controller (ArgumentError) in Ruby 3

I am creating a website were users can post jobs and users can login,register etc. I have created my jobs model and created my user model for the login/register part. When I try to load rails server I keep getting this error below and cannot figure out what I'm doing wrong or how to fix. I originally was trying to use devise and create the users model but was having issues so I deleted the files for it. I am wondering if I deleted something or if I am missing something in my routes.rb file. Can someone help or point me in the right direction? I will post my routes.rb file as well. Thanks for any guidance as I am still new to rails. The only thing I added to the routes.rb file was root :to => "sessions#login" and below that. Im sure other info in this was added when i created the models and controller.

/home/whitey7/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/mapper.rb:181:in `default_controller_and_action': missing :controller (ArgumentError)**

Routes.rb

Application.routes.draw do 
 get "sessions/login,"
 get "sessions/home,"
 get "sessions/profile,"
 get "sessions/setting"
 get "users/new"

 resources :jobs 



root :to => "jobs#index"
root :to => 'home/index'
 root :to => "sessions#login"
match "signup", :to => "users#new"
match "login", :to => "sessions#login"
match "logout", :to => "sessions#logout"
match "home", :to => "sessions#home"
match "profile", :to => "sessions#profile"
match "setting", :to => "sessions#setting"
like image 498
Awhitey98 Avatar asked Jun 24 '26 22:06

Awhitey98


2 Answers

I think you still have a route in routes.rb which in invalid. Please recheck all the routes, corresponding controller and action. Please also share the full error trace, that way we can pin-point the issue.

like image 71
Akshat Paul Avatar answered Jun 26 '26 11:06

Akshat Paul


Please check if the jobs controller is still there. Because this is the first root directive in your routes declarations (and still, it does not make sense to have more than one), Rails is checking if this root route is available. It seems that the jobs controller is missing and causing this error.

like image 24
awenkhh Avatar answered Jun 26 '26 13:06

awenkhh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!