On core website I use standard Devise configuration for user authentication. In routes.rb:
devise_for :users
Now, I have a namespace, lets call it “frame”, being used for display some views via some controllers in small window (or iframe) on remote page.
I need to authenticate user inside the frame, therefore I nested devise_for declaration:
namespace :frame do
devise_for :users
resources :albums, :only => :show do
resources :photos, :only => [:new, :create, :show]
end
end
To make the whole thing work I needed to create proper controller:
class Frame::SessionsController < ::Devise::SessionsController
layout "frame"
end
And now I use the following path to display form:
new_frame_user_session_path
HOWEVER. When I logged in via frame, *current_user* is nil, and I have *current_frame_user* instead. It’s bad, because the user logged in via core website (*current_user*) should be available via frame and reverse (in one browser).
Is there a little tweak to achive it or I should change the whole approach? Thank You for help.
The solution was for me to change the log-in form in views/frame/sessions/new.html.haml.
Instead of:
I needed to overwrite resource name:
Now I am able to log-in within the frame and the user’s session is coherent between the frame and the rest of the site.