Question

I'm trying to implement a feature where a user invites friend to the site, and the invited person will land on the page and view that page, but then when trying to view another page by clicking on a link, it asks them to sign up.

I was thinking about using Devise timeoutable and setting the session to 1.second for guest users. So it would be something like this:

class User < ActiveRecord::Base
  devise (...), :timeoutable

  def timeout_in
    if self.guest? 
      1.second
    end
  end
end

Is this the correct way of handling this type of situation? Or is there a better way?

No correct solution

OTHER TIPS

Maybe you can add authenticate_user! in your ApplicationController

class ApplicationController < ActionController::Base
  ......................

  before_filter :authenticate_user!

And skip the filter for the page you want guests to visit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top