title: use regex to accept any string after users/ link
body: <p>In my rails application I want to accept any string that comes after "users/" link. How do I do it? That is eg. <code>users/xyz</code> or <code>user/asdas</code> is acceptable. How do I do this?</p>
  
  <hr>
  
  <pre><code>def store_location
      # store last url - this is needed for post-login redirect to whatever the user last visited.
      if (request.fullpath != "/users/sign_in" &amp;&amp;
          request.fullpath != "/users/sign_up" &amp;&amp;
          request.fullpath != "/users/password" &amp;&amp;
          !request.xhr?) # don't store ajax calls
        session[:previous_url] = request.fullpath 
      end
    end
  </code></pre>
  
  <p>Okay, here is the full story. I have implemented this along with letting user to sign in only if he is approved. The catch is I need to do it for only one type of user so I implemented this in <code>registrations_controller.rb</code> by overriding it.</p>
  
  <pre><code> def create
      build_resource(sign_up_params)
  
      if resource.save
        # nil
        if !resource.has_role? :customer
        if resource.active_for_authentication?
          set_flash_message :notice, :signed_up if is_navigational_format?
          sign_up(resource_name, resource)
          respond_with resource, :location =&gt; after_sign_up_path_for(resource)
        else
          set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
          expire_session_data_after_sign_in!
          respond_with resource, :location =&gt; after_inactive_sign_up_path_for(resource)
        end
    else
      resource.approved=true
      resource.save
      # nil
      set_flash_message :notice, :signed_up if is_navigational_format?
          sign_up(resource_name, resource)
          respond_with resource, :location =&gt; after_sign_up_path_for(resource)
        end
      else
        clean_up_passwords resource
        respond_with resource
      end
    end
  </code></pre>
  
  <p>So customer alone can be directly approved but not others. So, when the users get the confirmation email and they click the link they get logged in but get confirmation token invalid error that is probably due to the page getting rerouted back to the confirmation token even on signing in and going to the root path which I have set in the <code>after_sign_in_path</code>. That is why I am trying a work around. </p>
  
  <p>Is this the error or is this something else?</p>