How about doing something like this ...
How you want to allow non-authenticated access only to the application’s main page:
That’s how I like to set up my app
1) in the route archive
# config / routes.rb
Rails.application.routes.draw do
ide_for: users,: controllers => {registrações: 'users / registrations',
sessões: 'usuários / sessões',
senhas: 'usuários / senhas',
confirmações: 'usuários / confirmações'
}
autenticar: o usuário faz
namespace: os usuários fazem
recursos: posts
root: to => 'channels # index'
fim
fim
recursos: contats
match "/ about_us" => "pages # about_us",: as =>: about_us, via:: todos
Páginas de raiz # índice '
fim
thus, all routes that are outside ** namespace ** users are public
I also create a master user controller that extended application controller like this
# app / controllers / user_controller.rb
classe UserController <ApplicationController
before_filter: authenticate_user!
fim
now for all device drivers
# app / controllers / users / registrations_controller.rb
Usuários da classe :: RegistrationsController <Devise :: RegistrationsController
privado
def after_sign_in_path_for (usuário)
user_root_path
fim
fim
My users' entire controller extends my user controller
# app / controllers / users / posts_controller.rb
classe Usuários :: PostsController <UserController
...
fim
You can follow this format for all other controllers. If you still need help, let me know.