문제

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?

올바른 솔루션이 없습니다

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top