Reputation: 43351
I have some custom views for Devise's SessionsController
. I am using scoped views so they are currently located at:
app/views/users/sessions
I need to move the views into a subfolder so that their new location will be:
app/views/public/users/sessions
I have specified the layout I would like Devise to use for these views in application.rb
using:
config.to_prepare do
Devise::SessionsController.layout "public/layouts/application"
end
But I see no way to specify the view path.
How can prepend public
to the path Devise uses to look up the views?
Upvotes: 1
Views: 452
Reputation: 13
I was trying to find our the solution, tried something and it worked:
namespace :public, module: nil, path: '' do
devise_for :users, path: ''
end
This will generate paths for example: /sign_in, /sign_out without any prefix, and uses the devise views from views/public/users directory
Upvotes: 0
Reputation: 76774
View Scoping
I don't know whether this will help:
#config/initializers/devise.rb
...
config.scoped_views = true
This is what Devise says about it:
Turn scoped views on. Before rendering "sessions/new", it will first check for
users/sessions/new
. It's turned off by default because it's slower if you are using only default views.
I guess that means if you have a custom sessions_controller
inside the /public
directory, it will switch the settings to suit?
Here's the documentation to support this
Upvotes: 0
Reputation: 43351
Doesn't seem to be possible without Overriding each controller and adding a view path using prepend_view_path
:
module Public
module Users
class SessionsController < Devise::SessionsController
prepend_view_path 'app/views/public'
layout "public/layouts/application"
end
end
end
Upvotes: 1