ruby on rails - Guest User for Devise using Null Object Pattern -


i trying implement guest user within devise, in doing user_signed_in? evaluates true how can around this?

i can't use signed_in? because have admin user if signed in on admin panel , go main website thinks signed in if use signed_in?

here code

application controller

def current_user   if devise_controller?     @current_user = super   else     @current_user ||= super || guest.new   end end 

view

<p>welcome <strong><%= current_user.first_name %></strong></p>   <ul>     <% if user_signed_in? %>       <li>         <%= link_to 'sign out', destroy_user_session_path,           method: :delete %>       </li>      <% else %>       <li><%= link_to 'sign up', new_user_registration_path %></li>       <li><%= link_to 'sign in', new_user_session_path %></li>      <% end %>   </ul> 

update

i have decided override user_signed_in? method, if devise_controller? breaking tests took out , changed applicationcontroller now.

application controller

def current_user   @current_user ||= super || guest.new end  def user_signed_in?   current_user.is_a? user end 


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -