Question

I read an article here and I used the principles found there to write a administration check for my controllers. Basically it checks to see what controller you're in and then I create an array saying if this person as permission to see that controller, than find, pass it on.

The author of the article said that readers shouldn't use the example code as it was flawed and that they should use his plugin (which of course is outdated now). And he said

"there are some issues with the above code when running in production mode due to the use of class variables and class caching."

I have a test failing and I think it might be due to this but I'm not quite sure what part of the code I shouldn't be using. I had the following (in application.rb):

 controller = params[:controller]
 action = params[:action]

But I changed that to:

controller = self.class.name
action = params[:action]

How do I access the action name correctly? And in general what kinds of things can you do in development mode that you can't do in production?

Was it helpful?

Solution

Have you considered a role based permissions plugin instead? See the following stackoverflow question:

Which Rails plug in is best for role based permissions? (Please provide one nomination per answer)

I'm unaware of any issues with production usage of the code you have pasted in. The plugin in question might have some issues due to a possible misuse of @@ however, I've not inspected it thoroughly.

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