You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Unable to get the values of the application constants from the constants defined in the environment.rb (or application.rb) for the authorization plugin in rails3
#4
Open
PratikNarkar opened this issue
Dec 13, 2010
· 1 comment
I have defined following constants in the config/application.rb present inside my rails3 application which are required for authorization plugin (used for access control)
AUTHORIZATION_MIXIN = "object roles"
LOGIN_REQUIRED_REDIRECTION = { :controller => '/homes', :action => 'index' }
PERMISSION_DENIED_REDIRECTION = {:controller => '/homes', :action => 'new'}
These constants added in the rails3 application's application.rb (or environment.rb) are not accessible inside the authorization plugin
The text was updated successfully, but these errors were encountered:
Solution:
Authorization plugin checks
if not Object.constants.include? "LOGIN_REQUIRED_REDIRECTION"
but in rails3 Object.constants returns array of symbols i.e. [:Object, :Module, :Class, :Kernel, :LOGIN_REQUIRED_REDIRECTION, :PERMISSION_DENIED_REDIRECTION, ...]
while previously (in rails 2.x) it was returning array of strings
Thus, Object.constants.include? "LOGIN_REQUIRED_REDIRECTION" returns false even if constant is present
To avoid this and to make the constants accessible from authorization plugin in rails3 application, we need to add the application constants to
config/application.rb file and change the constant in the string to symbol
i.e do following changes in the rails-authorization-plugin/lib/authorization.rb file
if not Object.constants.include? "LOGIN_REQUIRED_REDIRECTION" to if not Object.constants.include? :LOGIN_REQUIRED_REDIRECTION
if not Object.constants.include? "PERMISSION_DENIED_REDIRECTION" to if not Object.constants.include? :PERMISSION_DENIED_REDIRECTION
if not Object.constants.include? "STORE_LOCATION_METHOD" to if not Object.constants.include? :STORE_LOCATION_METHOD
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have defined following constants in the config/application.rb present inside my rails3 application which are required for authorization plugin (used for access control)
AUTHORIZATION_MIXIN = "object roles"
LOGIN_REQUIRED_REDIRECTION = { :controller => '/homes', :action => 'index' }
PERMISSION_DENIED_REDIRECTION = {:controller => '/homes', :action => 'new'}
These constants added in the rails3 application's application.rb (or environment.rb) are not accessible inside the authorization plugin
The text was updated successfully, but these errors were encountered: