kitz
kitz

Reputation: 889

Rails Routes does not work

I develop a rails 4 web application, and I have a problem:

My routes.rb file look like this:

Rails.application.routes.draw do
   root 'agregator#arata'
   devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
end

When I am not logged in and I try to acces http://localhost:3000 my rails app goes to http://localhost:3000/users/sign_in, although I set a root route at the beginning of my routes.rb file. If I'm logged in, the app goes where I want.

Mention I use devise for authentication, and this is first time when I use devise.

Can you help me?

Upvotes: 0

Views: 154

Answers (2)

bgreg
bgreg

Reputation: 49

I believe this is the expected behavior. If you access any properly setup controller without being signed in, it will route you to /users/sign_in. After you are authenticated it should then route to your root action.

Upvotes: 1

mswiszcz
mswiszcz

Reputation: 1006

Can you provide us with code from agregata controller? Probably you are checking here if user is logged in, and if not, devise will redirect to sign_in path. It may look like

before_action :authenticate_user!

in your agregata controller or application controller

Upvotes: 0

Related Questions