Solved

unknown error "store referer" rails, restful_authentication

Posted on 2010-08-13
1
659 Views
Last Modified: 2013-11-13
i am often seeing this error in my exception notification inbox. What is happening andd why is the user not seeing a nice flash error notification?

A NameError occurred in users#new:

 undefined local variable or method `store_referer' for #<UsersController:0xb69d33f0>
 [RAILS_ROOT]/lib/authenticated_system.rb:101:in `permission_denied'


def permission_denied      

       respond_to do |format|

         format.html do

           #Put your domain name here ex. http://www.example.com

           domain_name = "http://www.ndthub.com"

           http_referer = session[:refer_to]

           if http_referer.nil?

             store_referer

             http_referer = ( session[:refer_to] || domain_name )

           end

           flash[:error] = "You don't have permission to complete that action."

           #The [0..20] represents the 21 characters in http://localhost:3000

           #You have to set that to the number of characters in your domain name

           if http_referer[0..20] != domain_name  

            session[:refer_to] = nil

           redirect_to root_path

           else

             redirect_to_referer_or_default(root_path)  

           end

         end

         format.xml do

           headers["Status"]           = "Unauthorized"

           headers["WWW-Authenticate"] = %(Basic realm="Web Password")

           render :text => "You don't have permission to complete this action.", :status => '401 Unauthorized'

         end

       end

     end

Open in new window

0
Comment
Question by:depassion
1 Comment
 
LVL 14

Accepted Solution

by:
wesgarrison earned 500 total points
ID: 33437376
Looks like you need a method for store_referer() since it can't find it.

The point of that is that someone goes to /admin/dashboard and isn't logged in, you would store that and redirect them to the login page.  If they logged in successfully, they would be redirected to where they were trying to go.

If you don't need that functionality, just redirect them to the root_path and get rid of everything else in that action.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now