Skip to main content
added 9 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Store location with some excluded path, trying to make this more generic and simple

This code store instores the session last know location in the session. The location is not stored if it is one of the exceptions in ifthe if statement.

def store_location
    if request.fullpath != '/users/sign_in' &&
     request.fullpath != '/users/sign_up' &&
     request.fullpath != '/users/password' &&
     request.fullpath != '/users/sign_out' &&
     request.fullpath != '/accounts' &&
     request.fullpath != '/accounts/new' &&
     !request.fullpath.include?('/users/confirmation') &&
     request.fullpath != '/' &&
     !request.xhr?
     
     session[:previous_url] = request.fullpath
   end
  end

I need to make it more simple :).

Store location with some excluded path, trying to make this more generic and simple

This code store in the session last know location. The location is not stored if it is one of the exceptions in if statement.

def store_location
    if request.fullpath != '/users/sign_in' &&
     request.fullpath != '/users/sign_up' &&
     request.fullpath != '/users/password' &&
     request.fullpath != '/users/sign_out' &&
     request.fullpath != '/accounts' &&
     request.fullpath != '/accounts/new' &&
     !request.fullpath.include?('/users/confirmation') &&
     request.fullpath != '/' &&
     !request.xhr?
     
     session[:previous_url] = request.fullpath
   end
  end

I need to make it more simple :)

Store location with some excluded path

This code stores the last know location in the session. The location is not stored if it is one of the exceptions in the if statement.

def store_location
    if request.fullpath != '/users/sign_in' &&
     request.fullpath != '/users/sign_up' &&
     request.fullpath != '/users/password' &&
     request.fullpath != '/users/sign_out' &&
     request.fullpath != '/accounts' &&
     request.fullpath != '/accounts/new' &&
     !request.fullpath.include?('/users/confirmation') &&
     request.fullpath != '/' &&
     !request.xhr?
     
     session[:previous_url] = request.fullpath
   end
  end

I need to make it more simple.

Source Link

Store location with some excluded path, trying to make this more generic and simple

This code store in the session last know location. The location is not stored if it is one of the exceptions in if statement.

def store_location
    if request.fullpath != '/users/sign_in' &&
     request.fullpath != '/users/sign_up' &&
     request.fullpath != '/users/password' &&
     request.fullpath != '/users/sign_out' &&
     request.fullpath != '/accounts' &&
     request.fullpath != '/accounts/new' &&
     !request.fullpath.include?('/users/confirmation') &&
     request.fullpath != '/' &&
     !request.xhr?
     
     session[:previous_url] = request.fullpath
   end
  end

I need to make it more simple :)